I know a NT girl who does this. At least it sounds eerily similar to what she does.
Since you are a guy - is your hair long or short?
If long, have you tried a ponytail? You would have to make an effort to try to remember the reason why you wear a ponytail whenever you touch your hair though. That's tough, but it's possible.
If you hair is short, I'd go with what another members already said. Gel. If you're hands get all sticky, you are at least sure to notice that you are currently messing up your hair.
Have you thought of an alternative method that is similarly soothing and claiming as rubbing your hair at the same time? Do you have other stims/habits that have about the same effect as that one?
Alternatively, if you don't mind that your hair looks like 'just out of bed' yourself you could find a style/haircut that just looks messy naturally. Then, you can always say it's intentional if other people plan to get their knickers in a twist about how your hair looks like.
_________________
Autism + ADHD
______
The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it. Terry Pratchett