It's bacteria that feed off food residue left in your mouth into smelly (usually sulfur-containing) compounds. I eat onions and garlic all the time with no breath trouble. That's because I brush my teeth regularly. Keeping a good dental hygiene routine should prevent this: brushing, flossing, getting a check-up and cleaning regularly. And clean your tongue - it's a veritable hotbed for bacteria.