Is this behavior based on water quality in a tank? My other betta started doing this, sometimes i catch him doing it. He sometimes sits at the top of my tank and moves around in the tank and flares out at night. My tank has small abouts of tannins released from the mopani wood in the tank. If it is water quality, should i do a 50% or more change?
Rubbing against things is a symptom of Ich, I would suggest watching him closely and checking for little white spots on your fish. If you see any I would treat him for Ich. I personally don't do any treatments unless I know what the illness is.
Just keep a good eye on him for anything else that pops up.