Black walnut has been used for that, but it's never been scientifically tested to see if it actually works.
It's also known to cause stomach upset
, and due to the high tannin content found in black walnut, may cause liver or kidney damage
and may result in some types of oral, nasal, or esophageal cancers. Don't risk yourself to get rid of a worm. See a doctor for something safer.