Have Dog Health Questions? Ask a Dog Vet Online.
These are tapeworm segments that you are seeing (I presume). Dogs can get tapeworms from ingesting fleas or rodents. I will tell you what you can get to treat the tapeworms, but don't forget good flea control, or you will be seeing these again very soon!
It hasn't been very long that you could get the necessary medication over the counter. The active ingredient is called praziquantel. If you get a medication that combines this with either pyrantel or fenbendazole then you will also take care of other parasites that might be present. Here is a link to such a product.
Hope this helps! Let me know if you have any more questions regarding this.