Worms are normally excreted in feces. If you saw a worm come out while the bird is dust bathing, I'd inspect the bird for fly strike. It mightve been a maggot. Or maybe the chicken DID unknowingly dig up an earthworm. Of course if the chicken saw either, it would gobble them up.