Sorry try this:
As your granny probably told you, prevention is the best form of treatment. Good marine husbandry techniques (particularly use of a quarantine tank and dips) are typically helpful in stopping this pest (and many others) ever making it in to your aquarium. Planaria can sneak into the aquarium as a stow away on live rock, live sand, corals, clams and other live materials introduced to the aquarium.
If the worst happens and you find Planaria in your tank it is not all over - flatworms can be removed physically, biologically, or chemically.
Products such as Flatworm Exit can almost instantly kill off most or all flatwroms in your aquarium. Dying flatworms are toxic, so please be sure to read the instructions carefully - siphon out as many flatworms as possible before dosing the recommended amount.
The sea slugs of the family Chelidomura, sometimes called the head shield nudibranch can offer another biological solution. Although difficult to find through the aquarium trade, Chelidomura are obligate flatworm feeders, and will combat planaria. Reports of success are mixed. Chelidomura are frequently the victims of pump intakes and overflow drains. Those that survive, are reported as successful in the eradication of planaria populations. Once all the planaria are consumed you will need to find a new home for the Chelidomura.
You can also use a siphon to remove the critters. This can be combined with regular water changes, or if your tank has a sump and an overflow you could use your siphon with a micron bag. Place the micron bag in your sump to catch the overflow water and Use the siphon to suck the planaria from the nooks and cranies and divert the water with the planaria down your overflow. If using this approach do use active carbon to combat the potential release of toxins. Once finished take the micron bag and wash in fresh water. The planaria are extremely sensitive to fresh water and are killed almost instantly and completely dissolve within a few seconds.