It depends which kind of pet you mean.
Use the Feed Pet ability and then select a food from your inventory that matches the pet's diet. Diet matters: a crab eats bread, so any bread will do, while a cat needs meat. Feeding the wrong food simply will not work, so check the pet's information panel if you are unsure.
These do not need feeding to survive, but you can buy treats for them from the pet vendor in Dalaran.
Cannot be fed at all. They run on mana and spite, not snacks.