Well, its a mystery. It comes off in several episodes, but you never see it.
The best theory I've heard so far is, that when he was younger his parents disciplined him in a way similar to the method shown in "My Fair Ed". His parents could have used bandages on the back of his head and peeled them off whenever he misbehaved(and don't say that Edd is a perfect angel and he would never misbehave, all little kids get into some kind of trouble.) It could have damaged his scalp to the point where it was permanent and he would have to wear a hat for the rest of his life. It would also explain why he is so afraid of breaking rules.
So what do you think is under the Pandora's box that is Double D's hat?