This belief comes from 1 Corinthians 11:
Does not nature itself teach you that if a man wears long hair it is a disgrace for him, but if a woman has long hair, it is her glory? For her hair is given to her for a covering. (1 Cor 11:14-15)
There is more to the context, but this is the essence of the issue. When teenage boys started growing long hair in the 1960's, this verse was shouted from pulpits all over the nation. I was in my teens at the time, and lemme tell you, it got downright hostile. Walk by a construction site, and you were guaranteed to be called “pansy,” “faggot,” or worse.
Corinth was a 1st-Century Sin City. It was the hub of trade, where East met West and North met South. It was very prosperous and very immoral. One of the main trades was prostitution. The female prostitutes were identified by their short hair. This is why Paul wrote, “since it is disgraceful for a wife to cut off her hair or shave her head, let her cover her head.” (1 Cor 11:16) What was the disgrace to which Paul was referring? It was borne out of what the local prostitutes did. It was their call sign. In Rome, if a wife was caught in adultery, part of her punishment was to have her hair hacked off. The message was, if you want to act the whore, then look like one. (Nothing happened to the men who partook of the sin.)
There were also male prostitutes in Corinth. Want to guess what their “call sign” was? Long hair! When Paul asks, “Doesn't even nature itself teach you that long hair on a man is a disgrace?” he is not referring to the animal kingdom. Neither is he talking about God's nature, since God directed long hair on a man who took a Nazarite vow. (Judges 13:5) The only time Samson fell out of favor with God was when he lost his long hair. (Judge 16:19, 20) The apostle was referring to 'culture.' Normal men wore short hair while male prostitutes wore it long. Normal women wore long hair; prostitutes did the opposite. They were contrary to what was considered the norm, or what was natural.
A Christian woman doesn't need to wear a hat during church services. Unfortunately, many feel they are displeasing God by not following this “command.” Today, no one cares about men wearing long hair. Walk into any church and most women are not wearing hats and who also (GASP!) wear blue jeans. God looks upon the heart, and fine clothes can hide the darkest secrets.