A person who, Heaven forbid, eats food that is forbidden for consumption may not recite a Beracha before or after he eats. The Gemara says about a Beracha recited in such a case, "En Zeh Mebarech Ela Mena’etz" – this is not a blessing to G-d, but rather blasphemy, in that the person recites a blessing over an act which G-d Himself forbade. This applies both to food forbidden by the Torah and food forbidden by force of Rabbinic enactment.
There is some discussion concerning the case of a person who ate bread that was prepared with either milk or meat. The Sages enacted a prohibition against baking or eating such bread, as they were concerned that one who eats dairy bread might mistakenly eat it with meat, or, conversely, one who eats bread baked with meat might eat it with dairy products. (An exception is made when the bread is prepared in an unusual shape, such that it is easily identifiable as dairy, or as having been baked with meat.) As eating this bread is forbidden, one who violates Halacha by eating such bread does not recite a Beracha. Seemingly, he should not recite Birkat Ha’mazon after eating this bread, either, since the bread is forbidden for consumption. However, the Kaf Ha’haim (Rav Yaakob Haim Sofer, Baghdad-Israel, 1870-1939) boldly asserted that after one ate this bread, he should repent, verbally confessing and expressing remorse for his misdeed, and then recite Birkat Ha’mazon. The Kaf Ha’haim felt that repentance has the effect of retroactively erasing one’s transgression, such that he is no longer considered as having eaten forbidden food, and then he may recite Birkat Ha’mazon. Yalkut Yosef questions this ruling, noting that since the person did, after all, eat forbidden food, it would appear that Birkat Ha’mazon should not be recited.
Of course, this is not a common case, but it should perhaps remind us to be more vigilant about what food we eat, recognizing that besides violating Halacha by consuming such food, we end up "blaspheming" G-d, Heaven forbid, if we recite a Beracha over such food. Special care must be taken, for example, when buying salads. Many people assume that they can purchase a vegetable salad from an establishment that is not under Kashrut supervision, but this is not correct, as many vegetables need to be inspected to ensure there are no insects.
The Ben Ish Hai (Rav Yosef Haim of Baghdad, 1833-1909) once encountered a woman on Ereb Pesach checking lettuce for the Seder in a very casual manner, and he turned to her and asked, "How many threads of hair are on your head?"
"I don’t know," she said. "Why?"
"Because you might be deserving more lashes than the number of hairs on your head. Every insect one ingests carries a punishment of 195 lashes, and there may be many insects in this lettuce."
We must ensure that everything we eat meets acceptable Halachic standards in order to avoid Halachic prohibitions and so that our Berachot will truly be blessings, and not, G-d forbid, the opposite.
Summary: If a person, Heaven forbid, eats food that is halachically forbidden for consumption, he does not recite a Beracha, neither before eating nor after eating. According to one view, an exception is made in the case of one who ate bread which was baked with either milk or meat – which is forbidden for consumption – who should repent, confess and regret his violation, and then recite Birkat Ha’mazon.