Our Sages have established a great rule for us in Masechet Berachot: “Anyone who recites an unnecessary blessing (i.e. a blessing one is not obligated to recite), transgresses the prohibition of ‘Do not bear [Hashem’s name] in vain.’”
The great Rishonim disagree regarding the explanation of this Gemara. The Tosafot (Rosh Hashanah 33a) and other Rishonim are of the opinion that the prohibition of an unnecessary blessing is only rabbinic. The fact that the Gemara states that one who recites an unnecessary blessing transgresses the prohibition of “Do not bear Hashem’s name in vain” does not mean that this is an actual prohibition; rather, it is merely a rabbinic prohibition which our Sages based on the verse, “Do not bear the name of Hashem your G-d in vain.” (The reason why this is not considered bearing Hashem’s name in vain is because in any case, reciting the text of the blessing serves to praise to Hashem; it is permissible to praise Hashem using His name, as we customarily do by reciting Hashem’s name in Shabbat songs.)
Contrary to the Poskim who maintain that this constitutes only a rabbinic prohibition, the Rambam and other Rishonim are of the opinion that reciting an unnecessary blessing is a complete Torah prohibition; as long as one mentions the name of Hashem in a blessing one is not obligated to recite, one transgresses the prohibition of “Do not bear the name of Hashem your G-d in vain.” Maran Ha’Shulchan Aruch, whose rulings we have accepted, rules accordingly, that one who recites an unnecessary blessing transgresses the severe prohibition of mentioning Hashem’s name in vain.
The consensus of the Poskim is that whenever a doubt exists whether or not to recite a blessing, Halacha dictates that the blessing should not be recited. If one does recite the blessing when in doubt, one transgresses a prohibition, for by doing so, one enters the realm of possibly mentioning Hashem’s name in vain since it is possible that one has already recited the blessing on the food one wishes like to eat.
Thus, Maran Ha’Shulchan Aruch (Chapter 209) rules: “If one is unsure if one has recited any blessing or not, one should not bless neither before nor after [eating], besides for Birkat Hamazon which is a Torah obligation.”
This means that, for instance, if one is unsure if one recited the Shehakol blessing before drinking the water before him or not, the law is that he may drink the water in front of him and one should not recite a blessing, since “When in doubt regarding a rabbinic law, we rule leniently” and the basis for reciting blessings is only rabbinic in nature (as our Sages were the ones to enact the laws of blessings, see Berachot 15a). One is therefore permitted to drink without reciting a blessing. One may not act stringently and recite a blessing, for by doing so, one is possibly entering the realm of the Torah prohibition of mentioning Hashem’s name in vain.
Nevertheless, all of the above applies only to blessings which one is obligated to recite by means of a rabbinic enactment; however, regarding the recitation of Birkat Hamazon which is a Torah obligation, if one is unsure whether or not one has recited it, one must repeat Birkat Hamazon, for the law is that “When in doubt regarding a Torah law, one must act stringently.” Since one is obligated to recite Birkat Hamazon again as a result of this doubt, the prohibition of mentioning Hashem’s name in vain does not apply.
The obligation to recite Birkat Hamazon is only considered a Torah obligation when one has eaten and is satiated as a result of the food one has eaten. However, if one is not satiated, the obligation to recite Birkat Hamazon is only on a rabbinic level. Thus, Maran Rabbeinu Ovadia Yosef zt”l writes that if one is unsure whether or not one has recited Birkat Hamazon and one is not satisfied from the food one has eaten, one should not repeat Birkat Hamazon, for “When in doubt regarding a blessing, do not bless,” as we have explained.