Bacterial infection risk in work environments has been extensively reported for healthcare workers, while this risk is rarely researched in other occupations. This study aimed to identify occupational environments in Taiwan’s agricultural and healthcare industries with elevated bacterial infection risks by comparing risks for general bacterial infections and pneumonia. Using labour and health insurance claim data from 3.3 million workers (January 2004–December 2020), a retrospective cohort was constructed to estimate occupational infection risks with Cox regression and the Anderson-Gill extension. Significantly elevated hazard ratios were found for workers in vegetable growing, crop cultivation service, mushroom growing, flower growing, and fruit growing, ranging from 1.13 to 1.39 for general bacterial infections and 1.68 to 3.06 for pneumonia infections. In afforestation and the inland fishing industry, pneumonia risk was significantly elevated with, respectively, 1.87 and 1.21. In the healthcare section, especially workers in residential care services and residential care services for elderly stand out regarding their pneumonia risk, with significant hazard ratios of 3.49 and 1.75. The methods used in this study were proven to be effective in identification of occupation environments at risk and can be used in other settings. These findings call for prioritization of bacterial infection prevention by occupation.