Yeah, I agree with shygemini. It really depends if I'm actually hungry or if I just want food.
If I'm actually hungry, I get a healthy, low-calorie snack. Even if I'm at my calorie goal for the day. Honestly, if I go over my goal by 50 calories because I ate an apple, that's not going to derail my weight loss.
If I just want food, I find something else to do. I leave the house and go where there isn't any food (take a walk, go to a clothes store, take my daughter to a park, etc). Or I play a computer game (I don't like to eat at my computer) or call someone, or come on here and write about it in my diary.
Remember, if you aren't hungry enough to eat an apple (carrot, banana, yogurt, etc) than you aren't really hungry.
But, on the flip side, some times you feel like you just really need that cookie/ice cream/pizza. And, for most people, having a little bit once in a while actually helps you stay on track. When I get a really bad craving for something, I try to adjust my calorie intake for the day so I can have it in a small amount. Just try to keep this at a minimum, and avoid it altogether if you find you are the type that can't eat just one cookie or one piece of pizza.
Keep in mind that you are in charge, not the junk food. And the longer you go without it, the fewer cravings you'll get.