Kill the Worms
Before you bother trying to treat the holes created by the worms, you need to deal with the worms themselves, or they will simply create new holes in the wood after you attempt to fix it. Worms will be killed if you heat the wood, or if you have it fumigated. If you can heat the wood to a temperature of 140 degrees for more than 24 hours, the worms will die. Otherwise, you should have a professional fumigate the wood.
Use epoxy to fill in any wormholes that you want to repair. Epoxy is a good choice because you can actually inject it into the wood. This should fill in the hole more deeply than a surface covering or fill alone would accomplish. Epoxy is also strong. Wormholes make the wood weaker, and if the cavities aren't filled, the wood could break. Filling them with epoxy may make the wood strong enough again to survive longer without breakage.
Once you have structurally repaired the wood, you need to finish the repaired holes so that they blend in with the rest of the piece. Some people like the look of the holes, so if you have only a few surface holes you may decide to simply leave them. In other cases, the epoxy filling may look just like a small knot or wood defect. If you want a more seamless look, buy beeswax and dry tinting pigments. Melt some beeswax and use the pigments to create a filler that matches the color of your wood.
If you have wood products that have been affected by worms, you need to protect the wood from future attacks. Apply woodworm oil to your wood furniture and any other wood that you want to protect. An annual application of this oil helps to prevent the worms from attacking the wood. If you need to treat a valuable piece of furniture, be sure to test the oil on an out-of-sight spot before you apply a full treatment.