You decide when you cast the spell, not after waiting to see if it hits.
First, the spell explicitly says (emphasis mine):
When you cast a wizard spell of 1st through 5th level that deals damage, you can deal maximum damage with that spell.
This means that you can choose to Overchannel on-cast of a wizard spell of 1st-5th level which does damage as part of its effect, not that you choose to Overchannel when a wizard spell of 1st-5th level that you cast does damage.
If Overchannel allowed you to decide after hitting or after rolling your damage, it would be worded similarly to the Channel Divinity: Destructive Wrath feature of the Tempest Cleric:
When you roll lightning or thunder damage, you can use your Channel Divinity to deal maximum damage, instead of rolling.
On the topic of "that deals damage"
To clarify the ambiguity of how "when you cast a spell that deals damage" should be interpreted, look at the wording of the "Heart of the Storm" feature of the Storm Sorcerer:
In addition, whenever you start casting a spell of 1st level or higher that deals lightning or thunder damage, stormy magic erupts from you.
If "that deals damage" meant "when the spell you're casting deals damage" then Heart of the Storm would never trigger, as no spell does damage when you start casting it. Therefore, "that deals damage" must be a property of the spell itself (meaning it can do damage as part of its effect), rather than triggering only if a specific casting does damage (by hitting with an attack roll, for example).