We have a young cat - about 14 months. For the last six months or so she's been bringing in worms. We keep finding their dead bodies littered about the house. I have on occasion managed to rescue the odd live one which she was busy tormenting. Its rather embarrassing when we have visitors as sometimes we'll walk into a room and there will be a huge worm in the middle of the carpet!
She has toys but clearly sees worms as the most attractive toys of the lot.
I like worms but I like them in flower beds not in the middle of my nicely mopped kitchen floor! (ok floor mopping is not something that happens as often as it should in our house but when it does it would be nice not to have added worm)
I'm not sure that you can - other than restricting her going out at night. (She's almost certainly not digging them up, by the way. If you go out when it gets dark, you'll see that worms come out late at night and writhe/perambulate on the surface of the soil - so they're likely a tasty snack for a cat instinctively; and a tempting plaything.)
Enjoy it while you can. It will soon move onto bigger things like birds, mice, and squirrels. It is their natural hunting instinct to go out at night and catch animals. And you think a live worm is bad! Try a live squirrel up the blinds or a mouse in the walls...