Background: The BNT162b2 (Pfizer-BioNTech) two-dose vaccine regiment for children and the BNT162b2 third dose for adolescents were approved shortly before the SARS-CoV-2 omicron (B.1.1.529) outbreak in Israel. We aimed to estimate the effects of these vaccines on the rates of confirmed infection against the omicron variant in children and adolescents. Methods: In this observational cohort study, we extracted data for the omicron-dominated (sublineage BA.1) period. We compared rates of confirmed SARS-CoV-2 infection between children aged 5–10 years 14–35 days after receiving the second vaccine dose with an internal control group of children 3–7 days after receiving the first dose (when the vaccine is not yet effective). Similarly, we compared confirmed infection rates in adolescents aged 12–15 years 14–60 days after receiving a booster dose with an internal control group of adolescents 3–7 days after receiving the booster dose. We used Poisson regression, adjusting for age, sex, socioeconomic status, calendar week, and exposure. Findings: Between Dec 26, 2021, and Jan 8, 2022, we included 1 158 289 participants. In children aged 5–10 years, the adjusted rate of confirmed infection was 2·3 times (95% CI 2·0–2·5) lower in children who received a second dose than in the internal control group. The adjusted infection rate in children who received a second dose was 102 infections per 100 000 risk-days (94–110) compared with 231 infections per 100 000 risk-days (215–248) in the corresponding internal control cohort. In adolescents aged 12–15 years, the booster dose decreased confirmed infection rates by 3·3 times (2·8–4·0) compared with in the internal control group. The adjusted infection rate of the booster cohort was 70 per 100 000 risk-days (60–81) compared with 232 per 100 000 risk-days (212–254) in the internal control cohort. Interpretation: A recent two-dose vaccination regimen with BNT162b2 and a recent booster dose in adolescents substantially reduced the rate of confirmed infection compared with the internal control groups. Future studies are needed to assess the duration of this protection and protection against other outcomes such as paediatric inflammatory multisystem syndrome temporally associated with SARS-CoV-2 and long-COVID. Funding: None.