I'm so sorry your betta is poorly. While I can't offer any good advice regarding how to treat him I just wanted to give you some information regarding the microorganisms you're encountering.
There are numerous types of worms that can show up in an aquarium but from your description they are either
planaria or
detritus worms.
Planaria are a species of flatworm, they are thicker than detritus worms with an arrow shaped head. They are also believed to be omnivorous. These guys usually come in on plants and can be removed manually.
Detritus worms are often confused with planaria; they are thin hair-like worms that can be seen crawling up the aquarium glass or swimming through the water in "S" motions. They can range from very short to surprisingly long (sometimes up to 2 cm). Their purpose in an aquarium is to help the breakdown of mulm in the substrate. They are completely and utterly natural in an aquarium system but populations can explode due to one of three things: 1) a dirty environment 2) a newly cycled aquarium 3) new live plants. They can be removed manually and through regular siphoning of the aquarium substrate + water changes.
The other organisms you've spied may be one of a few things:
Cyclops look like a single teardrop shaped blob with a forked tail, they can dart through the water or crawl across the glass. They average a couple of millimetres in length from head to tail.
Daphnia are also known as water fleas and look just like fleas. They dart through the water. They can vary quite dramatically in size but usually average a couple of millimetres in length.
Seed shrimp swim like drunken bees through the water and can be surprisingly large, they range in colours from yellow to green. They can be up to a cm long.
Copepods are absolutely miniscule organisms that look simply like moving dots, they can swim through the water or be seen in huge numbers moving across the aquarium glass.
All of these things are natural in an aquarium and if you can't ever see any of them there may actually be something wrong but of course population explosions can be frustrating. They are all harmless and can be removed through extra water changes and gravel siphoning.
This website helped me a great deal when I experienced microfauna:
http://www3.sympatico.ca/drosera1/fish/worms.htm