Diatomaceous earth is also an effective treatment for tapeworms and other such parasites in animals. Probably works in people too, but I have neither a tapeworm nor a bag of DE so I can’t speak from experience on this one.
I realize a tapeworm is not an earthworm but this is the reason why I hesitated to incorporate DE into my gardening practices.
But not worms. Thanks for the link @Mithridate!