Depends on what the habit is, I'm not asking what the habit is but. some habits are easier to break than others and the longer you've had the habit the harder it is to break like smoking. There's no 100% way to break a habit, it takes determination and may take a counselor.
Best advice I can give is:
1. Slowly work away from the habit. If you try to break it immediately your going to have a harder time, I take it that the habit is important to get rid of immediately, but it takes time no matter what people say.
2. Replace the habit with something else. Be it hanging out with friends more often, doing something else more enjoyable or pick up something that is fun (no not flapping) like golf or getting fit. Just something to get it off your mind.
3. Support be it friends, family or whatever. Need someone to see you though the habit so you don't try going back. This helps on hard cases where you feel its too rough to stop. I know there's some habits you don't want to share what they are but having a best friend to be there and see you though it means alot.