Are you aware of what you are doing while you're doing it, but your defenses are down? Or do you only really remember it in the morning?
This article was in the NY TImes last month. You may need to register to read the whole thing, but here's an excerpt:
Sleep eaters “make a beeline for the kitchen” and tend to binge on sugary, high-calorie snacks, sometimes five times a night, said Dr. John W. Winkelman, medical director of the Sleep Health Center of Brigham and Women’s Hospital in Brighton, Mass. Some go for bizarre food combinations like peanut butter and pasta, and even the occasional nail polish or paper.
Consequences of nighttime eating can include injuries like black eyes from walking into a wall or hand cuts from a prep knife, or dental problems from gnawing on frozen food. On a deeper level, many sleep eaters feel depressed, frustrated and ashamed. Upwards of 10 percent of adults suffer from some sort of parasomnia, or sleep disorder, like sleepwalking or night terrors. Some have driven cars or performed inappropriate sexual acts — all while in a sleep-induced fog. About 1 percent, mostly women, raid the refrigerator.
I had a roommate once who did something like this. I got up once in the middle of the night to let my dog out and there she was in the kitchen eating a huge bowl of cereal. She was very health-conscious and didn't eat very much... I always figured it was her body's way of making sure she was getting enough calories.
If you aren't truly asleep, just lacking some willpower because you're out of it, how about tying your cabinets closed or something that would make it hard to get to the food? All the effort to get to it might get you out of your fog enough to help you change your mind.