You need to see your vet. It may just be some parasite that has to be treated but if it's maggots they can cause some serious damage very quickly and occur when there is something else that needs urgent treatment in most cases.
That's tapeworm. They generally come from fleas or eating the eggs from another animal who is infected. Don't use hartz products. Get a dewormer from your vet or a feed store.
It has eaten flies