Depends on the Pc and audio outputs and sound bar and audio inputs.
PC's can have varying audio outputs like Hdmi, optical and analogue jacks. Graphics cards can also be used as an audio device if it has Hdmi.
Sound bars can have inputs such as optical and analogue.
Using Hdmi from PC to Tv for video and audio is another possibility depending on your PC hardware and if your TV has Hdmi. Many Hdmi TVs can be used as monitors despite those having a PC connection port like dsub or Dvi, can still use Hdmi if it's available.
Not knowing your PC hardware and TV, explore these options and base sound bar connection types that can be utilised.
Gpu/Motherboard Hdmi -> TV -> TV Optical audio out -> sound bar with Optical. Motherboard Hdmi if available depends on your system setup and if using integrated graphics.
Motherboard Optical audio out -> sound bar with Optical
Motherboard analogue audio out -> sound bar with analogue inputs