Pet lines work because the animal gives you a reason to speak. Compliment the dog first and its owner second; people forgive a cheesy line far more easily when it starts with their pet.
Match the line to the animal in front of you. A cat pun said to a dog owner is a small but real mistake, and they will notice.
Dog parks, pet stores, adoption days, the vet's waiting room and any walk where two leashes are about to get tangled. They also make good messages for anyone whose profile picture is mostly their pet, which online is a large share of people.
Keep them light and never make the animal the joke. Owners will laugh at a pun about their dog's charm; they will not laugh at one about its weight. If the pet likes you, you are already most of the way there.

