Background and objectives: Breast cancer is a common cancer in women and has been the fourth leading cause of death in Taiwanese women. Risk factors for breast cancer include family history of breast cancer, genetic factors, and not breastfeeding. Several studies have reported an association between repeated inflammation at a young age, especially among lactating women, and cancer; however, the number of studies about the association of mastitis and breast cancer in nonlactating women is still limited. Therefore, the aim of this study was to determine the relationship between mastitis in women aged ≥40 years and breast cancer. Materials and Methods: This was a retrospective cohort study design. The data source was the Longitudinal Health Insurance Database 2010 (LHID 2010), comprising data collected by Taiwan’s National Health Insurance program. Cases of newly diagnosed mastitis in women aged ≥40 years (ICD-9-CM code = 611.0) were selected from the years 2010 to 2012. Women not diagnosed with mastitis were selected as the control group, and their data for the years 2009 to 2013 were obtained through the database. In addition, the non-mastitis group was matched 1:10 by age. Results: A total of 8634 participants were selected from the LHID 2010, which included 734 cases with mastitis and 7900 cases without mastitis. After adjustment for age, hypertension, hyperlipidemia, diabetes, hypothyroidism, and autoimmune diseases, the Cox proportional hazard model showed that patients with mastitis had a higher risk of breast cancer (aHR = 3.71, 95% CI = 1.9–7.02) compared with the non-mastitis group. The Kaplan–Meier curve also showed that women with mastitis had a higher risk of developing breast cancer. Conclusions: This study confirmed that women with mastitis have a higher risk of developing breast cancer. Therefore, women aged ≥40 years could reduce breast cancer risk by taking precautions to prevent mammary gland infection and mastitis.