Do we use the present or the past after "when" in a conditional sentence?
Solution 1:
Both are grammatical and mean ALMOST the same thing. The difference is that the second tends to convey the implication that plans have changed and what he said is no longer true – one can almost hear a "but" following the sentence.
He said we would get married when we get older.
Last night Billy told me we'd get married in a couple of years, when I'm 18.
He said we would get married when we got older.
Billy promised me that we'd get married when I turned 18, but then he ran off with that waitress.
Or you can take a slightly different point of view and read the first sentence as reporting what Billy said last night, while the second is reporting what Billy said 3 years ago – essentially the present (as near as one can report) vs the past.
Solution 2:
Interestingly, both sentences are grammatical, and they mean the same thing
-- at least they do in a context where all uses of we refer to the same two people.
- He said we would get married when we get older.
- He said we would get married when we got older.
Rules taught in schools about what verb forms must be used in conditional clause constructions normally refer to what you can say, not what you can't say. There is always a range of options.
Solution 3:
It's all about something called 'backshift'. With verbs of reporting that are in the past tense, like "said", you have the option to either backshift the tense, or keep the original present tense when you report what was said. The original utterance would have been in the present tense:
"We will get married when we get older".
But the report of it contains the past tense:
"He said we would get married when we got older".
However, you can keep the present tense instead of backshifting it, so both your examples are actually correct. Note that the verb in the matrix clause can also be backshifted (would) or left in the present tense (will).