I'm guessing it was for making them more visible to the troops under their commands but wouldn't something like a flag be more useful for that?
You're thinking of an officer's spontoon. It was an emblem of rank for a non-commissioned officer, like a sergeant. It could be used by them for signalling and directing troops, and was also used to dress the lines of soldiers in the field to keep them straight, as can be seen in this painting of the 1745 Battle of Fontenoy