The hijab, a head covering, primarily serves as a symbol of modesty and a means of protection from the male gaze within Islam. It also represents religious commitment and a way to express faith outwardly.
A Muslimess can take off her hijab in several situations, primarily when she is not around non-mahram men (non-blood-related) or when she is in a private setting where only women are present.
Generally, Islamic scholars consider a woman's head covering to be a requirement when she is in public and potentially visible to non-mahram men. Some Muslims believe not wearing hijab is a sin.
The hijab becomes compulsory once a girl reaches menarche, although some may start wearing it earlier, esp. to ease the transition.