This is tapeworm They are caused by ingesting a flea that contains a tapeworm egg. First, treat him with a monthly flea treatment like Frontline or Advantage. You will need a pill from your vet to get rid of the tapeworm as over the counter dewormers won't get rid of them. They will only treat hook and whipworm.
Once you do these 2 things, your dog will be just fine!
Please let me know if I can help further.