This information is from Mississippi State University:
"All poultry tapeworms apparently spend part of their lives in intermediate hosts, and birds become infected by eating the intermediate hosts. These hosts include snails, slugs, beetles, ants, grasshoppers, earthworms, houseflies and others. The intermediate host becomes infected by eating the eggs of tapeworms that are passed in the bird feces.
Although several drugs are used to remove tapeworms from poultry, most are of doubtful efficacy. In general, tapeworms are most readily controlled by preventing the birds from eating the infected intermediate host. Tapeworm infections can be controlled by regular treatment of the bird with fenbendazole or leviamisole."