I will answer myself, maybe it will be useful to someone. There were quite a few similar topics in different forums and I usually didn't see a specific solution there.
If we want the TV to play simultaneously sound from TV speakers + headphones (e.g. for a hearing impaired person) and we only have an optical output in our TV, you should buy an optical converter, such as the one given in the above answers. I have the cheapest one (Chinese for about PLN 50). And I must admit that it is enough for my needs. The first problem here is the inability to adjust the volume, which can be solved by having headphones with volume control.
However, there is one more problem, a very quiet output sound (in a TV, e.g. from Samsung, it is not possible to adjust the digital sound to, for example, strengthen it). I dealt with this problem so that I led the sound from the TV to the old DVD player, set the AUX mode in it and was able to output the sound to the headphones and get any volume.
And one more thing, if you ask why so much trouble with all this, you can output audio through the Euro connector, then the speakers will also work and I should be pleased. However, this does not fully fix the problem. When playing something from an external drive, USB flash drive or a browser built into the TV, there is no sound. The only option for sound in these cases is the optical output.
Thanks to this, my TV does not have to be loud and the hearing impaired person has headphones and can freely adjust the volume, regardless of me.