You can try it with another computer or another TV. Second, figure out if both sides of the ports are HDMI. If you are using VGA to HDMI or DVI to HDMI, they do not support audio. Third ...
For all the excitement and intrigue that goes into understanding a smart TV's screen technology, processing power, AI ...
All this said, if you do have HDMI ARC or eARC on your TV and your audio device, our advice is to use that over optical. It’s superior, no doubt about it.
The audio-visual world loves an acronym, so if you've heard about HDMI ARC ... No need for multiple volume controllers for the two different products – simply use your TV remote.