Whether a ruling becomes a house rule is entirely up to the DM. There is no rules for this. The intention, however, is that a DM will be fair and just to all players. Ideally, a DM should make it clear whether a ruling applies to only this situation, or to all situations.
For example, one of my players has a character that is a dwarven druid. He wanted to know, during the middle of a session and in combat, if the poison damage he took while wildshaped was subject to his dwarven resistance. I could not find the specifics in the rules quickly, so I told him that for this session, no it did not as his physical body had changed (much like he lost the darkvision his bear form didn't have), but I would do a thorough search after the session to determine if it should in the future. I don't recall off the top of my head whether my ruling was correct or not, but it worked well for my group because I gave a clear ruling, I gave it a scope, and I then did what I could to ensure we were following the rules of the game afterwards and clarified the ruling into the standard rule.
To summarize, if you have to make an ad-hoc ruling at the table, be sure to make it clear whether this is a one-time ruling, or will apply in the future. If you intend to make it a one-time ruling, be sure to clarify in the next session what the official rule should have been, and what it will be going forward, or if you are making it a house rule.
I'll provide a second example. Flanking is an optional rule in 5e, and one that is largely left up to the DM. Since most of my experience is in 3.5, and we were using a grid, I told all my players in the first session how flanking worked (using a traditional 3.5 method, where you had to be on opposite sides of the monsters). Since then, while encountering larger creatures, some questions about how flanking works were asked, and at the beginning of a later session, I updated how we handled flanking, making the new rule two characters who were adjacent to a foe, but not adjacent to each other, were considered to be flanking that creature. In both cases, this was a house rule, but I made sure everyone understood it clearly, and readily answered questions about the ruling if asked.
I will also mention that a DM is under no obligation to explain all the circumstances around an outcome. There are things the players simply wouldn't know (especially if it involves people more powerful than them). One of my favorite responses to a player who says "shouldn't X have happened?" is to say "Yes, it should have" and smile. As long as you aren't pulling it out of thin air, and there's actually a reason, it doesn't need to be revealed at that time (though avoid it in player vs player situations, as it looks like playing favorites).