Causes and prevention of ear infection in dogs. Prevention depends on identifying the underlying cause of the ear infection. In some cases the ear canal becomes moist from bathing, grooming or swimming. This moisture fosters the growth of microorganisms in the ear canal.