There are two types of ear infections:
Outer Ear Infection (Swimmer's Ear)
This can occur there is water left in the ear canal from a pool, bath, lake, river, ocean, etc... The liquid in the ear can allow bacteria to grow and potentially cause an infection. Swimmer's Ear can be prevented with ear drops available at any pharmacy. The drops contain alcohol or boric acid and speed the evaporation of water in the ear canal.
Inner Ear Infection
Studies show no link between this type of infection and swimming.