Because mastitis usually occurs in lactating females, the best prevention is to make sure your dog is spayed — especially if you’re able to have the procedure done before her first heat. If you do have a lactating dog, ensure her bedding is kept clean, check her teats daily for signs of infection and clip her pups’ toenails.
Sources:
Brum, Douglas. “Mastitis in Dogs.” PetPlace.com (April 14, 2011)
http://www.petplace.com/dogs/mastitis-in-dogs/page1.aspx
PetMD. “Bacterial Infection of the Breast in Dogs.” (April 14, 2011)
http://www.petmd.com/dog/conditions/endocrine/c_dg_mastitis
Ruben, Dawn. “Care of the New Mother Dog.” PetPlace.com. (April 14, 2011)
http://www.petplace.com/dogs/care-of-the-new-mother-dog/page1.aspx