These tips may help you avoid getting swimmer's ear:
Be careful when cleaning your ears. Most doctors advise against using cotton swabs unless you're using it to clean the outside of the ear. Instead, wipe the outer ear with a clean washcloth. Do not dig into the ear canal, and never use a pointed object. Scratching the skin of the ear canal can let germs get in under the skin and cause infection.
Avoid earplugs, if possible. These can irritate the ear canal.
After swimming, tilt and shake...