BACKGROUND: Myocarditis is more common after severe acute respiratory syndrome coronavirus 2 infection than after COVID-19 vaccination, but the risks in younger people and after sequential vaccine doses are less certain. METHODS: A self-controlled case series study of people ages 13 years or older vaccinated for COVID-19 in England between December 1, 2020, and December 15, 2021, evaluated the association between vaccination and myocarditis, stratified by age and sex. The incidence rate ratio and excess number of hospital admissions or deaths from myocarditis per million people were estimated for the 1 to 28 days after sequential doses of adenovirus (ChAdOx1) or mRNA-based (BNT162b2, mRNA-1273) vaccines, or after a positive SARS-CoV-2 test. RESULTS: In 42 842 345 people receiving at least 1 dose of vaccine, 21 242 629 received 3 doses, and 5 934 153 had SARS-CoV-2 infection before or after vaccination. Myocarditis occurred in 2861 (0.007%) people, with 617 events 1 to 28 days after vaccination. Risk of myocarditis was increased in the 1 to 28 days after a first dose of ChAdOx1 (incidence rate ratio, 1.33 [95% CI, 1.09-1.62]) and a first, second, and booster dose of BNT162b2 (1.52 [95% CI, 1.24-1.85]; 1.57 [95% CI, 1.28-1.92], and 1.72 [95% CI, 1.33-2.22], respectively) but was lower than the risks after a positive SARS-CoV-2 test before or after vaccination (11.14 [95% CI, 8.64-14.36] and 5.97 [95% CI, 4.54-7.87], respectively). The risk of myocarditis was higher 1 to 28 days after a second dose of mRNA-1273 (11.76 [95% CI, 7.25-19.08]) and persisted after a booster dose (2.64 [95% CI, 1.25-5.58]). Associations were stronger in men younger than 40 years for all vaccines. In men younger than 40 years old, the number of excess myocarditis events per million people was higher after a second dose of mRNA-1273 than after a positive SARS-CoV-2 test (97 [95% CI, 91-99] versus 16 [95% CI, 12-18]). In women younger than 40 years, the number of excess events per million was similar after a second dose of mRNA-1273 and a positive test (7 [95% CI, 1-9] versus 8 [95% CI, 6-8]). CONCLUSIONS: Overall, the risk of myocarditis is greater after SARS-CoV-2 infection than after COVID-19 vaccination and remains modest after sequential doses including a booster dose of BNT162b2 mRNA vaccine. However, the risk of myocarditis after vaccination is higher in younger men, particularly after a second dose of the mRNA-1273 vaccine.