56:6 If one completes an entire bracha said in error but he immediately realizes his mistake and corrects his words, he need not repeat the bracha. (Refer back to 56:3 for the definition of “immediately.”) For example, if he said his bracha thinking he had wine but immediately realized he had beer, with the result that he said “borei pri hagafen shehakol nihiyeh bidvaro,” it is nevertheless effective. (This leniency only applies to brachos that are rabbinic in nature. If one did this with bentching, which is a Biblical obligation, it would not be effective even after the fact. See Mishnah Brurah 209:6 for details.)
56:7 If one said hagafen over beer and did not immediately realize his error, he needs to recite the proper bracha of shehakol in order to drink. If he planned to also drink wine, he can drink some of that and then he would not need to say shehakol on the beer so long as he did not interrupt by speaking after saying his bracha of hagafen. Even if he already drank from his cup of beer, it would not be considered an interruption after the fact to prevent him from switching to the wine.