Welcome to BYC.
The worm in the photo appears to be part of an excreted tapeworm, there also appears to be a couple of tapeworm segments on the feces.
You're going to have to purchase Equimax equine wormer which contains praziquantel in order to kill the tapeworm. Your feed store should have it...