The science behind stress eating has shown that under stress the brain chooses the short-term reward, which is food. Food is also a comfort, which helps to relieve the stress for a short while. One study looked at MRIs of men and found that the stressed group chose unhealthy foods while the others did not. The brain during this time saw an increase in activity in the amygdala (areas of emotion and reward) and a lower level of activity in the pre-frontal cortex (areas of decision making and self-control). This shows that there is a physiological reason that stress eating occurs and that willpower alone might not due the trick. The best way is to remove the temptation (food) away from you while working, find healthy alternatives to reduce stress like working out, and if needed seek social support.
The video below explains the experiment that took place about stress eating: