Bettas do all kinds of strange things, and it is certainly possible nothing is wrong. However, if you feel like your betta is behaving oddly, here are a few things to think about:
Tank size: When fish are in very small tanks they often become restless and stressed. This could explain some of the frantic behavior you are witnessing. Consider a tank of at least 5 gallons for a single male betta.
Water Quality: Dirty water will also stress your fish, and combined with a small tank may result in odd behavior. Glass surfing is a term used to describe how fish dart up and down the sides of the tank. If this is what you are seeing, it means your betta is stressed in his environment.
Tankmates: If there are other fish in the tank with your betta, it could account for his stress. Betta can have tankmates in certain situations, but in other cases, it can be a disaster. You need to plan wisely.
Current: Because of their flowing fins, bettas do best in tanks with gentle currents. If he has to struggle against the current every time he leaves his cave it may appear he is darting around. Use low-flow filtration so he doesn’t have to fight the current so much.
Illness: Strange behavior in itself should not lead you to the conclusion that your betta is sick, but watch for other signs. Illness, of course, leads to stress in your betta, but stress also increases the chances your betta could get sick. This is why it is important to keep your fish as stress-free as possible.