Diagnosis
This is typically caused by the soundbar's input auto-switching feature getting confused by a signal it thinks is a Bluetooth pairing request, often from a nearby device like your phone.
How to Fix It
First, on the soundbar remote, press the 'Input' button until 'OPT' (for optical) is selected and displayed on the front panel. Then, disable Bluetooth on all nearby devices—your phone, tablet, laptop—so they can't broadcast a pairing signal. If the problem stops, you've found the culprit. To prevent it long-term, after you select OPT, press and hold the Bluetooth button on the remote for about 5 seconds. This should put the Bluetooth into a 'pairing' mode that will time out and become inactive, making the soundbar less likely to auto-switch.
If That Didn't Work
There might be a low-level electrical signal or interference coming through the optical cable that the soundbar misreads as a command to change inputs. Try a different optical cable if you have one, and make sure it's firmly plugged in at both the TV and soundbar ends.
Heads Up
The auto-switch function is designed to be convenient but can be a nuisance. If you never use Bluetooth, the most permanent fix is to never pair a device in the first place. Once paired, the soundbar remembers that device and will listen for it.