obviously optical cable will be used to send signal to a device that can generate electricity, else it's going to be hard to get sound from a an electrical coil ^_^.
usually optical will stick to transmit digital data, so from a source to a DAC. and that's it for audio purpose.
Just to add... Optical/Toslink operates in a single direction only, as does coax. That may seem immaterial, but between a DAC and computer there can be some benefit to a little bi-directional hand-shaking, like with USB. It is possible to put an optical receiver, DAC and amp (and battery) inside headphones. Probably not an advantage, though, and would be costly.
the bonus is that it can get pretty well isolated from the rest of the electrical circuit, so it's a good way to avoid noises from a computer.
the malus is that it tends to be more jittery than most other means of streaming digital signal.
We have to be careful here. Technically, the bitstream on optical/Toslink, SPDIF Coax, and AES/EBU are all identical, and self-clocked. While poorly performing cables of all kinds can degrade any of them, one is not superior to the other in any way, including jitter. It may be more correct to say that, for similarly priced and unusually long cables, optical may degrade sooner than, say, coax. But it's a cable quality issue, not the style of transmission. With good quality cables, they compare well. In any case the typical cable-induced jitter is below audibility.
Please note, there is no such thing as UltraHD audio. Optical lacks the bandwidth to transmit muliti-channel TrueHD and DTS Master Audio, and is somewhat limited to two channels of PCM audio, though high sample rates and bit depths are supported. But that's built into the standards, any compliant optical cable should pass anything within current standards.
Optical cables do not transmit HD video signals.