I've never seen or experienced anything like this, so take my comments for what they're worth, i.e. virtually nothing.
If these critters are subsisting on particles and bits of uneaten food, then starving the worms shouldn't necessarily mean cutting off feeding altogether. I try to select food items or pellets that are sized such that the fish being targeted will eat the entire pellet at once; too large a pellet forces the fish to break it down, producing the fine crumbs of food that encourage pests like snails and these disgusting worms. Too small a pellet, and feeding becomes tedious; it's difficult to make certain that each pellet is eaten. I drop the pellets or other food items in carefully, in ones and twos or at most in small quantities, and watch to make sure that all are eaten and that all the fish get their share. Depending upon the species I am feeding, there are many tanks where a pellet virtually never hits the bottom.
I don't think that feeding should ever consist of littering the bottom of the tank with pellets, and then hoping that the fish will find and eat them all. If something about the stocking of the tank encourages or necessitates this method, then a bottom-cleaning/vaccuming immediately after each meal...not hours later, or tomorrow, but immediately as in a few minutes later...should be undertaken.
Caveden
, your tank decor, lol, lends itself to easily keeping the bottom spotless.
Like I said earlier, I've never experienced an infestation of worms like this; maybe (likely!) my anal approach to feeding is to thank for that.
Rocksor
, I had a large Lungfish as well, so I am familiar with those fecal logs you are dealing with. Try as you might, you can never get them all before the fish manages to pulverize some of them. If the worms are subsisting on the nutrients in the poop, is it reasonable to assume that perhaps a lighter feeding regimen would encourage more complete digestion of the food, and so less undigested food material in the poops? I'm just guessing here; I know I wasn't successful in removing each and every poop before it was spread all over the place, but I never saw these worms appear in my tank. My Lungfish was fed once or twice weekly, and kept lean and mean. Maybe his poops were just too thoroughly digested to encourage worm growth?