I don't know of any "good" worms.
If you've got worms in your tank it's a sign of over-feeding or inadequate filtration. So figuring out the cause is key to keeping them from coming back.
This particular specimen looks flat and rusty colored to me, which would be indicative of the "bad" kind of Planaria. Detritus worms would be long and skinny.
The easiest thing you can do, albeit the most extreme measure, is to treat the tank with Fenbendazole.
Fendebdazole, commonly sold as Panacur C (a dog de-wormer) will send Planaria into oblivion within 2-4 days.
Panacur C (Fendebdazole) Dosage for Aquariums
You'll need 0.1 grams per 10 gallons.
Be sure to remove any carbon or chemical media, as well as any snails if you have any (and want to keep them).
If you're having trouble with the measurement (requires a kitchen scale), you can take a 1 gram packet and dissolve it in a 500 ml of dechlorinated tap water or tank water. In this case you'll dose 50 ml per 10 gallons.
Re-dose after 48 hours. Then wait another 24-48 hours (You'll know when they're dead).
Follow this up with a massive water change (~80%) using a gravel vac to pick up the casualties and add a carbon to your filter and let it suck up any remaining meds. Remove it or replace it after 24-48 hours.
I always wear nitrile gloves and a mask when handling any medications.