Give your tamed pets (dogs, cats, horses and more) to another player
Get a Book & Quill
Write the player name of the new owner in it (the player must be online)
Sneak + look at the pet you want to transfer with the Book & Quill in your hand
You're done!