Removing your hat is considered to be a gesture of respect for certain occasions and in certain places. Keeping your hat on during these occasions and in these places is a gesture of disrespect.
All hats, including baseball caps and knit caps, should be removed when the wearer is indoors, including in private homes and restaurants. Although it is not necessary for the hat wearer to remove his hat in public places such as lobbies, corridors, and elevators.
Hats should be removed during the singing of the National Anthem, the passing of the American flag, funeral processions, and during formal outdoor occasions such as weddings and dedications.
After removing your hat, hold it so that the inside of the hat is toward you and not visible to others.
Some people believe that it’s bad luck to put a hat on a bed. So when you take your hat off in someone’s home, look for a hat rack or some other place to put it.