I've fished for salmon, steelhead and whitefish in our rivers here, trout and Kokanee in local lakes, and crappie when I used to own a property that had a pond.
I've never found worms in any of the fish I've caught, but if there might be some you can't see, frying the fish or cooking it to a high temperature would kill any harmful parasites.
Way back in the day, I worked in the kitchen of a seafood restaurant during college, and the Sushi chefs used to find the occasional worm in the raw fish. The way they sliced the fish so thin, they were able to get rid of every worm, as well as every piece that had contacted a worm. They were extremely skilled chefs, they taught me a lot but I could never do what they do without years of training and practice.
I did get pretty good at filleting different species of fish, deveining shrimp safely, learning how to broil, bake, fry, and saute most fish, and cook the usual dishes associated with each fish or shellfish to a decently tasty standard. Makes me far from an expert, though. The chefs I worked with were true artists. I'm just grateful to have learned enough basics from them to cook the fish I catch these days so many years later, with a few different ways to prepare them.
If you're worried that a freshwater fish you caught might contain worms, including worms too small to see, you could always fillet the fish, then soak the fillets overnight in a brine marinade. This will draw the worms out. Then rinse off the fillets before you cook them and toss out the possibly-wormy brine. For saltwater fish, do the same with a vinegar marinade.