For Hunter Pets: If you've already named them once, you need to obtain a Certificate of Ownership which is made by Inscriptionists.
For Battle Pets: Just open your Shift+P (pet/mount window) and right click the pet you want to name/rename.
Warlocks are not allowed to rename their pets.