A google search turns up enough conflicting information to make me chuckle
half will tell you the white worms are planaria. the other half will tell you such worms are detritus worms. Either way they, in and of themselves, are not a bad thing, they just are.
the common denominators on the web are these..
1) they are harmless in small numbers
2) in massive numbers they can lower oxygen levels in the aquarium (not very well supported on the web)
3) they thrive on the organic buildup on the substrate surface (poo, old food, plant matter)
4) they have been shown many times to be present in perfectly healthy aquariums, though others say its a sign of dirty water, or poor maintenance.
I had a 10g with just a single betta in it and a small pleco. The tank did fine, the fish did just fine (still have the pleco today) and the worms were at one point almost boiling out the top.
Ive lost all my fish with no worms, and at the same time ive had the worms in alot of my tanks from time to time, and didnt lose any fish. I have to conclude that they, in and of themselves, be them planaria or detritus worms, are harmless.