Prevention is better than cure when it comes to swimmers' ear. It happens due to water repeatedly getting into your ears, washing away the protective oils and waxes and softening the skin. This allows detergents, chemicals and bacteria to get in, causing irritation and infection. Infection of the ear canal is called otitis externa, it can spread behind the ear drum; otitis media and then into the inner ear, otitis interna. Once you've got it you need to see a doctor for ear drops and sometimes oral antibiotics. You can prevent it by wearing swimming earplugs which fit well, keeping the water out.
Colourful swimming earplugs are easier to find when you inevitably drop them on the floor in the changing rooms. If you choose ones connected by a cord you are less likely to lose them in the pool. Available from ZenPlugs. Some of them are even antibacterial which can help reduce the chance of infection further.
ZenPlugs Molded Earplugs are great at keeping water out of your ears because they are individually molded to you ear canals from a kit. They are antibacterial so they may help prevent swimmers' ear.
Available in bulk. They are available in a range of colours and can be connected with a cord or lanyard to stop you losing them on the swimming pool floor. If you are wearing them with a wetsuit you can tie them to your zip on your back so you don't lose them.