Part of the problem is purely practical. Choose a hairstyle that doesn't
involve having to sling or brush one's hair out of one's eyes,
essentially giving an unnecessary chiropractic adjustment or messing up
eye makeup.
The first step in breaking a habit is realizing you're doing it. You've
generally realized you would like to change things. Think about catching
yourself the moment before you are about to do it. Doing this is much
trickier than it would at first seem to be.
The other is preventative. How is your posture contributing to the issue? Are you hanging your head over your body while looking down... and then peering up through the tangle of your locks? Solve this by remembering to look up every once in awhile, and once your head is over your body from having looked up, then tip your face forward to look ahead and continue with whatever else you were doing. Looking up will move your head so it's located over your body by default, and it also rests your eyes from being fixed. Sometimes looking up will also encourage your rib cage to tip so your back is straighter... instead of hanging your head out of your shell like a turtle. Between your shoulders will feel better too if you change this unnecessary head slump routine.
How long does it take to change or establish a new habit? Sixty-eight repetitions, or about thirty days - since eliminating a habit isn't really something you can learn to do by "practicing" it. But - you can practice not doing it when you're not at work, while you wear your hair up when you are at work.
The most common experience of this first challenge of being aware of yourself is usually realizing that you're doing it again. You become aware of your actions after you're already playing with your hair. Drat! Resist the urge to admonish yourself for being so unaware. Recognize the power of habit is really, really much stronger than your choice to not do this thing - so far.
The usefulness of will power is actually over-rated. The smart thing to do is to devise sneaky ways to challenge this status quo. Get strategic! Figure out the situations where it's likely to happen and use these situations to pay attention to your responses, not to "stop yourself." Your established habit is installed in response to a need. There's an elegant solution available if you can determine that need that originally put the habit into place. Think of how you'd train your dog without punishing.
Part of the strategy of finding the motive is to avoid changing anything you're doing, but merely watch yourself doing the thing you do not want to do. At that moment, it pays to ask yourself "what came before I was about to do it?" At some point, you're going to become aware that you were about to do it... This is a cause for celebration! As you trace back to the moment before that, there will be a gem of insight - an emotional feeling that motivates you to do that objectionable habit. Tolerate that emotion if you can, and experience it. It's valuable information. Ask yourself where or when in your life this feeling was a common one... This information will probably tell you when you designed the habit to address a repeating situation.
Now you can let up, play with your hair and think about what else you could do to address those urges when they come again. Sometimes, you have to experiment to find something that is effective enough to fulfill the same need that drives the reaction. Try out your bright ideas, take them for a spin. Sometimes the solution is merely being aware of oneself and knowing that nobody else really knows how you feel and you enjoy keeping the secret.
Once you do find some other way that is more appropriate to respond to that need and have acknowledged it, it doesn't happen again - strangely enough - without you being aware of it. Unlike many habits that reinforce themselves and will only die out over time, if you can get to the emotional root of why you do it - you've solved the issue.
Cool, huh?
Such habits are not gender specific as men too have their own way avoiding getting more nervous/hold their nerves like playing a pen or a paper weight while talking or dealing with a serious subject/issue and many times men hide their fingers in their pockets-coat or trousers to hide this habit.