The DM decides when rounds start, and usually this is at the beginning of actual combat. I don't see any particular reason you couldn't start dodging right away — and, in fact, telling the DM that you want to do this would usually start the beginning of combat rounds. (With the DM saying "okay then, roll initiative").
Dodge is described in the rules under "actions in combat". Previously, in the Adventuring chapter under "speed", it's noted that character and monster speed "assumes short bursts of energetic movement in the midst of a life-threatening situation". Although the combat chapter doesn't spell this out, I think it's completely reasonable to assume that the same applies: these are short-term high-adrenaline actions that you can't just keep up all that time. So you can't say "I'm always dodging unless I'm doing something else!" — that would completely exhaust even a high-level adventurer. The same chapter also explains that:
In combat and other fast-paced situations, the game relies on rounds, a 6-second span of time described in chapter 9 [the Combat chapter].
I added the emphasis — the important point is that while rounds are used in combat, that's not the only time they might apply.
So, indicating that you're ready to enter one of these high intensity bursts of compressed time represented by rounds is the normal way to go. In other words, to answer the title question you can dodge before combat starts, but doing so would start timekeeping in rounds.
You don't have to do it this way, though, and in fact, I think the normal approach would be to use the Ready action. This is technically also something you do in combat rounds, but in every D&D game I've seen, it's exactly what people do when they want to be prepared for something before combat has started per se. People arrange their readied actions, and possible out-of-rounds times happen, as other players set out what they're doing or where they're positioned (for a limit of a few minutes) until the first trigger occurs.
Here, you say "I'm going to ready to dodge when I see a creature on the other side of that door". This works out rationally, because Dodge requires you to be able to see the attacker to work, so there's really no point in having it "active" before that.
On the other hand, Dodge reflects a greater level of alertness all around (as modeled by advantage on Dex saves), and I think it's equally reasonable to say "I'm going to walk into that room on high alert — effectively, I'm taking the dodge action as I go in."
Either way, of course, prevents you from making an attack on your first round, even if there's obviously an enemy there to engage. That's the price of caution!