This is a good collection of advice on how to break a bad habit.
Here are the first 3 steps:
Step 1: Define the habit. What is the behavior you want to stop?
Step 2: Identify your trigger. What is the cue that sets you off? It can be subtle — a time of day, a memory, an odor, an emotion or a set routine. Ask yourself: I do this habit whenever I [fill in the blank]?
Step 3: Identify the reinforcement. What are you really getting out of this action?