There are a couple of things you can say like

> Your pet was lucky to have you.

This is how you can remind them that how great they were at taking care of their pet. This might help them get over the grief. ([Source][1])

You can also try saying that their pet had a great life because of them. For this, you can remind them some great events they had with their pet. Though it's not compulsory, you can try it. There is only one setback of this. Some people might, but not every time, mourn over this too much after you remind these events.

Once my neighbor lost his pet and I tried reminding how much fun he had and how great he was at taking care of their pet. This helped and he said thank you.

If someone lost their pet due to some illness, they might be feeling the guilt of not taking the pet to a vet on time. In this case, you can say,

>You did everything you could do.

You can check [this][2] and [this][3] for some great tips as well.


  [1]: http://www.care2.com/greenliving/what-to-say-not-say-to-someone-who-lost-a-pet.html
  [2]: https://www.everplans.com/articles/what-to-say-to-someone-grieving-the-loss-of-a-pet-and-things-you-should-never-say
  [3]: https://www.thespruce.com/sympathy-etiquette-for-the-loss-of-a-pet-1216544