Ultimately, I'd like to see this modified to have a requirement that you take care of your pet in order to keep the pet's loyalty.
I'm picturing it as a pet-specific variable that can take positive or negative values. The more positive the variable, the greater the loyalty. The lower the value, the more likely that the pet will 'rebel'. If it's sufficiently negative when the pet rebels, it will turn hostile. If it rebels (less likely) in the midrange, then it will simply lose interest.
As for *how* to influence the value (I'll call it "Pet Loyalty"):
1. Pet Loyalty naturally decreases over time, not entirely unlike piety (but always decreasing, not moving towards zero).
2. Pet Loyalty can be increased through feeding the pet. Different pets prefer different foods, and there are foods that certain pets simply will not eat. In this sense, also somewhat like piety. Pets could also have a second variable, "hunger"; if at the maximum, Pet Loyalty starts to decrease at an increasing rate. If at zero, you can't continue to feed the pet, because they're simply not hungry at all.
3. Pet Loyalty can be increased through healing the pet after it has been injured. Conversely, injuring the pet yourself significantly reduces Pet Loyalty (note that it doesn't immediately turn the pet hostile, in this case, unless the pet is already significantly negative in loyalty).
4. Certain classes get reductions in Pet Loyalty decay in certain situations; Farmers for race-based pet species (Human farmers have Big Dogs, for instance), Druids for any "natural" pet species (dogs, cats, bears, etc), Merchants for humanoids (influenced by Charisma, though), and Bards in most situations.
5. Some pets have preferred "gifts" that can also influence Pet Loyalty. For instance, Big Dogs will take bones even if not hungry, while many of the "Chaotic" humanoid species, such as Goblins, like to be given weapons.
Now, as you might imagine, leaving a pet unattended for a significant period of time would result, due to Pet Loyalty decay, in a pet that may become disinterested or even hostile. This provides an impetus to keep the pet with you, so that you can keep it happy with you.
Hmmm... maybe I should make this a separate feature request.