Harmful bacteria in the mouth cause infections. The best preventative measure is adopting a good oral care routine. Brush your teeth twice daily with a toothpaste that helps prevent plaque build-up and gingivitis, clean between your teeth daily, and rinse with antiseptic mouthrinse to kill germs. Make sure also to keep hydrated since saliva helps clear your mouth of harmful bacteria.
If you're a smoker, you should know that it makes you more susceptible to infections because smoking contributes to poor oral hygiene and poor periodontal health. If you have multiple salivary gland infections a year, talk to your doctor about your risk factors and the best prevention methods for you.
Salivary gland infections can be easily treated by a healthcare professional. Keep these symptoms in mind and keep up good oral hygiene habits to prevent bacteria from causing an infection.