If there is a lot of them, it's probably because the substrate has too much uneaten food/waste. The majority of worms that can be found in freshwater aquariums are harmless. The only way to know for sure is to identify the worm. If you manage to get a picture of them, post it here, and I'm sure someone can identify it!
You can always do a gravel vac and suck as many up as you can to get rid of them. I found a bunch of red worms in my filter when I first started my big tank, and I freaked out! But then I found out that they were harmless, and the fish actually eat them. after cleaning the canister, they never showed up again.