Garlic contains allicin, a sulfur-containing compound that is known for its antibacterial and antiviral properties. Allicin helps fight infections, which could be the underlying cause of the cough, such as viral or bacterial respiratory infections like the common cold, flu, or bronchitis. Some studies suggest that garlic may help inhibit the growth of pathogens in the respiratory tract, which can reduce inflammation and irritation, thus alleviating cough symptoms.