to do what you want i believe you would need it set up in one of two ways.....
a) have a soundcard with optical input such as the soundblaster z. however, on the z you would need to set the optical output to pcm and not run it in dolby digital. this means that you will effectively be limited to 2.0 and 2.1 sound.
b) run the optical output of the ps4 to an audio extractor (basically a dac, digital analog coverter) and run the rca output jacks to a soundcards line-in input jack.
---Option B is essentially what I am doing, although I don't have a sounds card it is connected into the motherboard. I should also say that I am a noob, there might be a basic error I have committed, I'll just give a basic rundown of what I did. I took and optical cable and pluged it into the ps4, I then proceeded to take the other end into the converter, on the other side of the converter i plugged in a white and red rca cable, which on the other end is a 3.5mm male. I plugged the male end into a light blue slot on the back of my motherboard. I have not edited any settings or messed with drivers. Theoretically I can't see why this wouldn't work. Maybe some stuff I need to change. And thanks for the reply
if your end result is only to play sound over the same speakers your pc uses then there is an alternative setup which can use 5.1...
you could use a 5.1 hdmi audio extractor with hdmi video passthrough to pull 6x rca outputs of analog sound from the hdmi stream while forwarding video to your tv/monitor via the hdmi output. then you would use 3x rca to stereo 3.5mm cables to take those outputs and convert them to 3.5mm.
from there you could either a) plug your speaker system into the box manually every time you want to switch sources or b) use 3.5mm splitters on each input of the speaker (3x splitters) so that you can have both connected. be aware that you can only have one device on at a time if you do this. or if you used 3.5mm switches you could have both systems on at once and just flick a switch to transfer the channels over.
or if you had a system such as a z906 you could just have one system via optical and one via 3.5mm