They are called Planaria and they are (as RTR mentioned) a sign of excess food or nutrients in the tank. I notice that a new tank is a bit more prone to getting these than a mature tank (if both are fed equally). They don't bother your fish a bit, and may even be a food source for younge fry or tiny fish.
Reduce feeding a bit and maybe increase water changes. Paying attention to the substrate during cleaning is a big factor!