The most basic way to increase the happiness of your pet is by feeding it. One feeding will give the pet 10 bites of food, distributed over 20 seconds. Depending on the quality of the food, each bite will give 8, 17 or 35 happiness, for a total of 80, 170 or 350 per feeding. You can follow the gain in happiness in the combat log. If your pet attacks or is attacked during the feed period, the feeding is interrupted.

However, glyphs and talents allow ways of increasing (or maintaining) a pet's happiness without food.

With the [Glyph of Mend Pet], the pet gains happiness whenever the [Mend Pet] spell is used. Feeding pets is not necessary with this glyph. A big advantage of the glyph is that it allows the pet to gain happiness while it is in combat. A pet cannot fight and gain happiness via [Feed Pet] because it stops eating when entering combat and won't eat while in combat.

Ferocity pets may learn the [Bloodthirsty] talent, which allows them to gain happiness during combat. This can allow the hunter to get away with not carrying any pet food at all, provided the pet is used in combat frequently enough to allow the talent to proc. Tenacity pets may learn [Guard Dog], which increases happiness whenever [Growl] is used.

It has been reported that the death of a pet causes a loss of 350 happiness.

Abandon

When you go out of range of your pet (either while it is in combat or you made it Stay) and it disappears, it loses 10 happiness. Hunters can use this rather than Dismiss Pet as it loses less happiness.

Not helping

There are suggestions that letting a pet kill a mob on its own while not helping will cause the pet to lose happiness.

Mounting up will make your pet disappear, but it will not make it lose any happiness. The pet does not lose happiness over time while the Hunter is mounted.

CataclysmPatch 4.1.0 (patch date::26-Apr-2011): The Happiness/Pet Loyalty System has been removed. Hunters will no longer have to manage Happiness for their pets, and the previous damage bonus for pets being happy will now be baseline for all tamed pets.