If you have a choice, then it would usually be best to connect a soundbar with an HDMI connection. This is mainly because HDMI connections allow for more audio formats, and you can control your devices using HDMI CEC commands. However, an optical connection will be fine if you just need stereo audio or Dolby Digital and DTS 5.1 surround sound.