The Shulhan Aruch (Orah Haim 91) rules that a person must have his head covered when reciting a Beracha. Similarly, the Rambam writes that one must have his head covered when praying.
Rav Moshe Feinstein (1895-1986), in Iggerot Moshe (4:40:14), wrote that if one prayed without a head covering, his prayer is considered a "To’eba" (abomination), since he prayed in a manner resembling members of other faiths. Even if one’s Kippa fell off without his knowing, and he then prayed with his head uncovered, his prayer is invalid and he must repeat the prayer with a Kippa.
Hacham Ovadia Yosef, however, disagreed. In a letter of approbation for the work Nesah Yosef (cited in Yalkut Yosef), Hacham Ovadia wrote that he felt that Rav Moshe Feinstein went too far, and one who mistakenly prayed without a Kippa certainly does not have to repeat the prayer.
There is also a debate among the Poskim as to whether one may think words of Torah in his mind, without saying them, with his head uncovered. Some ruled that this is forbidden, but Hacham Ovadia Yosef writes in Yabia Omer (vol. 6) that this is, technically, allowed, since Halacha follows the opinion that thinking words in one’s mind is not Halachically equivalent to reciting them ("Hirhur Lav Ke’dibur"). Hacham Ovadia also ruled that one may answer "Amen" to a Beracha without wearing a Kippa, though quite obviously, one should try to ensure that he is wearing a Kippa when answering "Amen" and thinking words of Torah.
Rav Moshe Feinstein ruled stringently also with regard to the question of greeting a fellow Jew whose head is uncovered with the greeting of "Shalom." Since "Shalom" is one of the Names of G-d, Rav Moshe explained, it may not be uttered without a Kippa, and by extending such a greeting to one’s fellow, he will cause the fellow to respond "Shalom," in violation of this Halacha. According to this ruling, then, it would be forbidden to extend the greeting of "Shabbat Shalom" to a Jew who is not wearing a Kippa. However, Hacham Ovadia disagreed, for several reasons, including the fact that "Shalom" is not among the Names of Hashem that it is forbidden to erase, and therefore, it is not treated with the same level of stringency as other Names.
However, even Rav Moshe permitted saying the English word "G-d" without a Kippa. And thus, for example, one who teaches in a public school and does not wear a Kippa is allowed to recite the Pledge of Allegiance with the class, even though it includes the word "G-d."
Summary: One is required to wear a Kippa when praying or reciting a Beracha, though one who mistakenly prayed or recited a Beracha without a Kippa – such as if it fell off without him realizing it – does not have to repeat the prayer or the Beracha. Strictly speaking, one does not need to wear a Kippa when thinking words of Torah, or when answering "Amen," but this is certainly preferable. One may say the English word "G-d" without a Kippa.