The key is to reflect upon the actual benefits derived from a habit.
Say, like my Inc. colleague Justin Bariso, you want to stop watching YouTube videos when you know you should be working. The next time the urge strikes, don't fight it. Watch a video. But don't do it mindlessly: Think about what you're watching. Is it entertaining? Do you gain any value from it? Is it more fun -- or more rewarding or fulfilling or satisfying -- than doing something else? What do you really get out of it? Do that enough times, reflect on the actual feelings and benefits that result from a habit, and in time you'll start to make a different choice.