You've probably enjoyed a pizza topped with garlic and onions and worried that your breath smells after eating. Particles of food get lodged between teeth when you chew, and the bacteria in your mouth start to break them down. This produces certain byproducts, and for foods like onion and garlic, these byproducts can be especially pungent. Not only do these compounds stick around in your mouth, they enter your bloodstream during digestion, and are then carried to your lungs and exhaled in your breath.
Drinks like coffee and alcoholic beverages can contribute to halitosis, too. Both can dehydrate you, which reduces saliva flow and allows halitosis-causing bacteria to build up. And during alcohol metabolism, pungent byproducts can also be exhaled via the lungs.
You should feel free to eat the foods you love, but if you find that certain foods make your breath stink, keep a portable mouthwash or some sugar-free gum handy.