The Shulchan Aruch writes: “It is forbidden to mention Hashem’s Name or to enter a shul while one’s hair is uncovered” (91,3). The halachah does not differentiate between men and women, implying that this applies to both. Do women in fact need to cover their hair for tefillah?
Married women are obligated to cover their hair and do not go outside with their hair uncovered. This is considered the dignified way to dress, and is the way they would greet a distinguished person. Since this is their normal mode of attire, the custom is that they cover their hair when reciting Shemoneh Esrei, even if no one else is around (Rav Shlomo Zalman Auerbach as cited in Halichos Shlomo 2).
Since the Shulchan Aruch does not distinguish between married and unmarried women, some halachic authorities suggest that single girls should also cover their hair for tefillah (Yaskil Avdi Vol. 7, p. 289; Yabi’a Omer 6,15,11). In practice, this opinion has not been widely accepted, and the custom is that most unmarried women pray with their hair uncovered (Rav Shlomo Zalman Auerbach as cited in Halichos Shlomo 2,17, Ohr L’Tzion 2).
Custom or Obligation?
“Rav Huna brei d’Rav Yehoshua would not walk four amos with his head uncovered. He sensed the Shechinah above his head and that it was disrespectful to the Divine Presence to walk without a kippah” (Kiddushin 31a). From the actions of Rav Huna brei d’Rav Yehoshua, we infer the halachah that a man should not walk four cubits if his head is not covered (Shulchan Aruch 2,6).
During the times of the Gemara, wearing a special head covering was not considered obligatory. Today, in most communities, this practice has become an accepted custom. As such, one is obligated to wear a kippah.
Halachic authorities cite another reason why a man may be obligated to wear a kippah. Since Christians consider it honorable to take off their hats, especially in holy places, anyone who goes bareheaded today violates the Torah prohibition of “going in the ways of non-Jews” (Taz 8,3)