When a person recites Kiddush on Shabbat, the Beracha of "Boreh Peri Ha’gefen" which he recites over the wine covers the wine he then drinks during the meal. Meaning, if a person recites Kiddush, and then after "Ha’mosi" a new bottle of wine is brought to the table, he does not recite "Boreh Peri Ha’gefen" over that wine, since that wine is covered by the Beracha he recited during Kiddush. The reason for this Halacha is that Kiddush is integrally connected to the meal. There is a rule of "En Kiddush Ela Be’makom Se’uda," which means that Kiddush must be recited in the framework of a meal. This Halacha establishes a connection between the Kiddush and the meal, and therefore the Beracha recited at Kiddush covers the wine drunk during the meal.
The Halachic authorities discuss the parallel situation when one eats the Melaveh Malka meal immediately after Habdala. Would the "Boreh Peri Ha’gefen" recited over the wine at Habdala cover the wine one drinks during the Melaveh Malka meal? Seemingly, according to the rationale mentioned above, the Beracha should not cover wine drunk during the meal. Unlike Kiddush, Habdala does not have to be recited in the context of a meal, and there thus seems to be no substantive connection between Habdala and the Melaveh Malka meal which one eats afterward. We would therefore expect that after Habdala one would be required to recite "Al Ha’gefen," and if he then wishes to drink wine during Melaveh Malka, he must recite "Boreh Peri Ha’gefen."
However, according to one view among the Halachic authorities, if one recites Habdala at the table where he will then be eating Melaveh Malka, the Beracha recited during Habdala covers wine drunk during the meal. The fact that he recites Habdala at the table and will immediately be proceeding to the meal establishes a connection between Habdala and the meal, such that the "Boreh Peri Ha’gefen" covers wine drunk during the meal. Other Halachic authorities disagree, and maintain that the Beracha does not cover the wine drunk during the Melaveh Malka, unless one had washed Netilat Yadayim for the meal before Habdala. Halacha permits washing Netilat Yadayim for the Melaveh Malka before Habdala, because Habdala does not constitute a Hefsek (interruption) as it is necessary for the meal. According to this view, in such a case the Habdala is considered connected to the meal, and thus one would not have to recite a Beracha over wine during the meal, but otherwise, if one washes Netilat Yadayim after Habdala, he would have to recite a Beracha over wine during the meal.
In light of this debate, the Shulhan Aruch (Orah Haim 174:4; listen to audio recording for precise citation) rules that if one recites Habdala before washing Netilat Yadayim for Melaveh Malka, he should have specific intention that the Beracha over the wine should apply only to the wine of Habdala. This way, according to all opinions he will be required to recite "Boreh Peri Ha’gefen" over wine drunk during the meal, and he thereby avoids this controversy.
Summary: If one is eating Melaveh Malka immediately after Habdala, he should have in mind that the Beracha of "Boreh Peroi Ha’gefen" recited during Habdala covers only the wine of Habdala. He should then recite "Al Ha’gefen" and proceed to wash Netilat Yadayim for the Melaveh Malka meal. However, if one chooses to wash Netilat Yadayim before Habdala, then the Beracha recited over the wine at Habdala covers as well the wine he will drink during the Melaveh Malka meal.