How to cast Youtube video, but keep sound in headset?
Robert's answer in comment:

When casting an online video your smartphone simply tells your TV
which web address to play. The audio is never processed by your
smartphone. Therefore it can not be played by the smartphone. Better
connect the headset to your TV.

So not possible the asked feature, but you need to connect your headset to your TV.