You have everything connected properly, it just doesn't f'kn work. Welcome to HDMI and the world of ARC and eARC audio.
You would have to go into the TV to ensure that HDMI audio is enabled, which it sounds like it is since you are getting it from other devices plugged into the receiver. Onkyo is also notorious for not always having the most reliable firmware, so that could play into it. But, mostly, manufacturers just can't seem to get any real standard in place which will actually work properly all the time.
The best practice is typically to plug all your sources directly into your AV receiver (Onkyo) and allow it to process that audio properly and pass video onto the TV. The TV will always stay on the same input, but the receiver will switch to new inputs as your switch sources. For audio from TV viewing, if eARC doesn't work, you can still use the optical audio output from the TV into the Onkyo. It isn't the 'best possible' way to do things, but as you already know, it is a solution that actually works reliably, which is often more important. I mean, if the choice is TV speakers, or your bookshelf speakers, then find a way to use the bookshelf speakers. But, the reality is that the TV shouldn't ever be used for direct content playback. That's what you have a computer, cable box, and Roku for.