I would suggest buying a simple small safebox. There are different sizes and grades of security, and they are usually available in hardware stores. Then i'd drill two holes in such way that allow the safebox to be bolted to the water bottle mounts on the bike. The screw heads would be accesible only if the safe is open, so it wont be easily removed.
Another option is using U-bolts. Of course leaving the fasteners inside the box. This allows to mount the box somewhere in the bike. A third option is hose clamps, but those may be too easy to break, so, not safe at all.
This is the one that came to my mind for this example. This particular model, has a cable loop that is secured with the same lock that closes the safe, so it can be secured independently to anything, including the bike itself. I suggested bolting it to the frame to make it a more permanent solution and not having to hold it somewhere else when riding. Take int account that depending on the material grade the safe is made of, drilling it may be way too difficult to perform with typical DIY-er home-shop drills and tools.
I like CardMechanic's answer for bigger items like a jacket or dry after-the-run clothes, extra drinks or food.
I take your house key scenario just as an example. In my case, I'd do this for bike tools, energy bars or things like that, because I think it is too much trouble and risk for just a key. Imagine if someone, just for the sake of evil, curiosity (A locking box attached to a bike means there is something worth locking in it), etc, broke into the safe and seeing your key, decided to take it or throw it in a trash can... (wherever). What would be the backup plan for something like this?
If a Key is small enough to hide it inside a handlebar, seat post or similar, I hardly think it is so big that can't be taken with you on the running. Most keys are actually flat, so, have a copy made, and do not use a keyring, Now you can have it on your wallet (I used to carry a spare of my car key in my wallet because I was very prone to lock the car with the key inside). Or use paracord to group it with your bike lock key. A key can be also attached to a wristband, or a belt, etc.
If you are willing to risk leaving the key on the bike on a public space, you may be better hiding a spare key outside your house. Or, if your car key is smaller than your house key, leave the latter on the car and carry the car key instead.