Vaccination is the most effective way to prevent pertussis. The DTaP vaccine (diphtheria, tetanus, and acellular pertussis) is recommended for children, while the Tdap vaccine (tetanus, diphtheria, and acellular pertussis) is recommended for adolescents and adults, including pregnant women. Vaccination not only protects the individual but also contributes to herd immunity, reducing the spread of the disease in the community.