The rear brake light is activated by one of two switches, one is activated by the front brake lever and the other is activated by the rear brake pedal. Either one of these switches could be causing the problem you describe. I would check the rear brake switch first because it readily accessible and easy to adjust. The rear brake pedal is connected to a metal rod that is connected to a spring that is connected to the brake light switch. With your lights turned on, pull up on the spring and see if the bake light goes off. It it does, then this switch needs to be adjusted.
Try this first and then report back.