I assure you that for a given individual person, assuming everyone else isn't doing the same, eating a clove of fresh garlic or a fresh onion each day, spaced out throughout the day will decrease the chances of contracting COVID-19, or of spreading it to others.
Mostly because it encourages others to socially distance themselves.
Of course if EVERYONE does it then it'll get pretty hard for anyone to smell the difference, so no, it won't work as a general measure