Long-serving Barcelona defender Carles Puyol has announced he will leave the Catalan giants at the end of the season.