Roundworms, Hookworms, Whipworms, Tapeworms, Heartworms - there are many internal parasites (worms) that invade our pets.
A rice-looking grain in your pet's excretment is likely a piece of tapeworm. When freshly excreted they move and appear flat. Tapeworms are introduced into the animal when they eat a flea carrying the egg(s) of the worm. The worm attaches to the intestine and grows long, in segments that break off and exit in the animals feces.
http://www.canismajor.com/dog/worms.html (for pictures)
Medications for tapeworms are best from your vet since the commercial products may not address the particular worm, could aggravate other conditions and/or cause any of a number of other bad reactions.
If your animal is on heartworm medication, vet monitored meds for any/all other parasite (worm) infestations is necessary. If your animal has any history of thyroid or liver disease (or anything else) - medically supervised treatment is necessary.
Roundworms and Hookworms are most typical in puppies and they're often the cause of big, round belly. These worms are picked up from the ground and while adult animals don't usually have them, pregnant mothers can pass the eggs on to her unborn pups (explaining why so many puppies are born with worms). Worming the mother has no effect - the puppies must be treated.
The dose and type of medication for these worms truly needs regulation. While you can buy over the counter treatments, caregivers who value their little ones and want to do it right and do it once - will just make a vet visit and have the litter taken care of. In the long run, it's much less expensive than trying to correct a problem caused by the commercial med and possible complications.
Whipworms live higher up in the intestine and many times aren't visible in excrement. If/when they are, they are often seen as short pieces of string with a flat end. Not only is vet diagnosis necessary for these, but again, professional treatment recommended.
Pinworms migrate out of the body (through the anus) at night, deposit their eggs and most then die. Checking your pet's tail region at night with a regular flashlight should reveal these pests - and care needs to be taken since these are also among the most common parasites in children (with less than perfect hand washing habits).