I have two main tricks to stay on track. The first trick is to keep my eating habits very simple and the same every day for the whole week.
I figure out what I need to eat each meal to keep my diet nutritionally sound. I will then eat that same breakfast, snack, lunch and dinner for the whole week.
This keeps things simple enough to remember albeit somewhat boring. A good mixer is to throw in some various lean cuisines (or similar) for one of the meals.
I keep plenty of fresh fruit in the house, low-ball myself with about 200 calories/day and allow myself a fruit snack any time I feel hungry.
This is no way to live though and so I allow myself one cheat day a week. I eat whatever I want, bagel with cream cheese for breakfast, pasta Alfredo for lunch and steak for dinner. This is also the one day I'll allow myself to drink alcohol.
Giving myself one cheat day a week where anything is fair game makes it a lot easier for me to keep on track. If I allow myself a little treat here and there during the week I fall off the wagon in no time at all.
I've also found that it doesn't take much to make me feel very self indulged on my cheat day so the chances of going totally overboard and eating up all the calories I lost the 6 days prior are very slim.