Garlic, as many chagrined garlic-bread lovers have discovered, has surprising staying power. Twenty-four hours after eating the stuff, a pungent scent still lingers on the breath and even in the sweat. In fact, one doesn't even need to put the garlic in one's mouth to get garlic breath.

In 1936, doctors reported in the Journal of the American Medical Association that a patient who'd been given garlic soup through a feeding tube had it on his breath a few hours later. Another doctor wrote that he had experienced something similar after delivering the baby of a mother with “a very decidedly obnoxious garlic odor to her breath.” Soon after birth, “I was surprised and rather amused to note that the child also had a strong garlic breath odor,” he wrote. “On occasion I have mentioned this to other men and they usually think that I am attempting to be facetious.”

The reason garlic breath can happen to people who haven't even chewed the stuff themselves, like babies and feeding-tube patients, is that garlic is stuffed with sulphur compounds that are released into the bloodstream after being digested. Whisked along by the blood, they seep out into the lungs and up the throat and out the mouth. No amount of brushing your teeth will get rid of it – the smell comes not from any garlic hanging around your mouth but from chemistry happening inside you.

Fighting chemistry with chemistry, it turns out, is a better approach. Some years ago, Sheryl Barringer, a scientist at Ohio State University who studies how volatile molecules contribute to flavour, had a student ask her about doing a project on garlic breath. There was some research on foods that, if eaten alongside the garlic, seemed to destroy the odour: some top performers included lettuce, chicory, celery, potato, parsley, mint leaves, peppermint, basil, and mushroom. But not as much was known about why. Barringer and a number of students since have looked to see just how well certain foods eliminate garlic breath and how, exactly, they do it.

If eaten alongside the garlic, some foods seemed to destroy the odour  

Lettuce, mint, and – somewhat surprisingly – apples have been a focus so far. “Apple is one we discovered accidentally,” says Barringer. A student who'd eaten garlic and sipped water, as a control experiment, saw surprisingly low levels of odour molecules. Going back through everything eaten that day, the student remembered eating an apple a couple hours before. Lo and behold, when they tried chewing a bit of apple after eating garlic, down went the odour.

The group's latest paper, which came out in September last year, traces the odour-killing power to a likely chemical reaction between four of garlic's sulphur compounds and a set of other molecules called phenolics. Volunteers chewed garlic, along with a smorgasbord of other options, and exhaled into a mass spectrometer, which detected the molecules on their breath. The researchers also mixed crushed garlic, water, and either pure enzyme or certain phenolics, including rosmarinic acid, found in mint, and had the mass spectrometer sniff these as well. Right away it was clear that raw apple, lettuce, and mint were better performers than heated versions. That indicates that enzymes, which help catalyse chemical reactions but fall apart at high temperatures, are probably involved.

Of all the options, mint makes the most sense, says Barringer. Mint has very high levels of phenolics, to begin with. For a chemist, it's easy to look at rosmarinic acid and garlic's sulphur compounds and see very clearly just how this bit here would attach to this bit there and produce a molecule with no smell at all. Apples have a lower amount of phenolics, though still a decent helping. But lettuce had the least of any substance tested, far less than even green tea, which had no deodorising effect at all. “That's where I would say we don't completely understand what's going on,” says Barringer. Pure enzyme on its own did not do much to reduce most of the sulphur compounds, the team found. But in combination with phenolics, enzymes are probably behind the somewhat mysterious effects of lettuce.

By making use of this still-not-totally understood chemical dance, you can tame garlic breath. But lest we forget, no amount of deodorizing will change the fact that humans are living, breathing chemical factories. The things we exhale or sweat out can reveal not only what we've eaten in the last day but the presence of certain bacteria camping in our mouths, and even whether we have certain diseases.

Scientists are exploring how molecules in exhaled breath could be used to diagnose lung cancer, and whether using electronic noses to sniff blood, urine, or tissue samples couple reveal tell-tale volatile signatures of everything from ovarian cancer to brain damage. While keeping one's stench to a minimum is a common courtesy, it's interesting to think that there may be something of value, after all, encoded in it.

Join 700,000+ Future fans by liking us on Facebook, or follow us on Twitter, Google+, LinkedIn and Instagram

If you liked this story, sign up for the weekly bbc.com features newsletter, called “If You Only Read 6 Things This Week”. A handpicked selection of stories from BBC Future, Earth, Culture, Capital, Travel and Autos, delivered to your inbox every Friday.