If a person hears a Beracha or Kaddish while he prays, and he had just recited in his prayer a verse that speaks of calamity, idolatry, or some other negative topic, should he answer "Amen" to the Beracha or Kaddish?
Consider, for example, the case of a person who hears Kaddish as he recites Shema, right when he says the verse, "Ve'chara Af Hashem Bachem" ("The Lord shall be incensed with you"). If he exclaims "Amen" at this point, it sounds as though he express his wish that this ominous warning should materialize, Heaven forbid. Or, if a person answers "Amen" during Aleinu, after he recited the words, "She'hem Mishtachavim La'hevel Va'rik," which speaks of the idolatry of the pagan nations, it sounds as though he gives his support for pagan practices.
For this reason, the Chesed Le'alafim (work of Halacha by Rabbi Eliezer Papo, Bulgaria, 1785-1828) ruled that in such a situation one should forego on the response of "Amen" and continue praying, rather than give the impression that he expresses his support for a curse or some other undesirable phenomenon. This is the view as well of the Ben Ish Chai (Rabbi Yosef Chayim of Baghdad, 1833-1909), in the end of Parashat Ki-Tisa.
Chacham Ovadia Yosef, however, in his work Halichot Olam (vol. 1, p. 247), disagrees, arguing that one is not excused from the obligation to respond "Amen" in such a case. After all, the Almighty is aware of and is concerned with what a person thinks in his mind, and therefore one should respond "Amen" to the Beracha or Kaddish regardless of whatever undesirable matter he has just mentioned in his own prayer. Chacham Ovadia adds, however, that a person should try to avoid such a situation; if he anticipates hearing Kaddish or a Beracha, he should try to ensure that he does not recite at that point a part of the prayer describing something negative.
Summary: If a person hears Kaddish or a Beracha while he prays and he has just mentioned something undesirable, such as a warning of punishment, he should nevertheless respond "Amen" to the Beracha or Kaddish. Ideally, however, one should endeavor to avoid such a situation.