●Otitis media (OM) is a common infection in children but its risk factors still remain unclear.●We examined key air pollutants and critical exposure windows in the development of OM.●Both outdoor and indoor air pollutants were significantly associated with OM onset.●Prenatal outdoor exposure and postnatal indoor exposure were associated with childhood OM.●Combined exposure to indoor and outdoor air pollution significantly increased OM risk.