NHS website says 'You should avoid swimming for at least 24 hours after having a piercing, and ideally until it has healed properly. While it's still healing, it's important to keep the piercing dry as there's a risk of infection.'
I've heard of people putting tape or something over it while swimming to keep it dry though.