The sooner a child gets used to being in water, the better. There are many classes available for babies and parents and although the children don't learn to swim so young, they build their confidence early on. My son started taking swimming lessons at the age of 2.5 years. By the age of 6 or 7 he was a very confident swimmer, able to go boogie boarding, snorkelling and has enjoyed many water sports since then.
I agree with all of the below, as soon as possible. That way your child will become a more confident swimmer with more practise, and hence acquiring a valuable skill. Sadly, I learnt how to swim at age 11. The earlier the better.