It is not unusual that Balimbing fruits are infested with “worms” that make them unfit for eating. And you ask, how did the worms get inside the fruit?
The worms that you are mentioning are actually the larvae of the fruit fly which deposits its eggs in the fruit. When the eggs hatch, they are the “worms” you are talking about. They feed on the flesh and soon the fruit will no longer be suitable for eating. Who would like to eat Balimbing with worms?
Here’s how you can prevent fruit fly infestation. Bag the fruits when they are about three inches long. You can use bag made of fabric. A cheaper one would be bagging the fruit with newspaper and then putting a transparent plastic bag to prevent the paper from getting wet. You can cut a small portion of the bag at its bottom corner so that air can get inside, thus avoiding sweating inside.
It is that simple if you keep your Balimbing tree low-growing. You can plant it in a rubberized container and the tree will bear full-sized fruits as long as you fertilize it regularly.