The rule you are referring to is called the backshift. In general, if one is reporting what someone said in the past, then every verb is shifted one level back in time. However, if a certain condition holds, then the backshift is optional. That condition is this (CGEL, p. 156):
It must be reasonable to assume that the temporal relation between the
situation and the reporter's time of utterance1 is the same as that between
the situation and the original time of utterance.
1CGEL actually says 'deictic time' instead of 'time of utterance'. This distinction is unimportant for our purposes here. In any case, the deictic time is very often precisely the time of utterance.
So, for example, provided that it is still the case now that Jill has too many commitments, both of the following are acceptable:
Jill said she had too many commitments.
Jill said she has too many commitments.
Provided the condition quoted above is satisfied, there are various factors that affect the decision of whether or not to backshift, including (CGEL, pp. 157–158)
(a) Reporter's attitude to the content
If I endorse the content of what I'm reporting, then the non-backshifted version is more likely than if I don't.
She said she doesn't need it, so I'll let Bill have it. [accepted: non-backshifted]
She said there was plenty left, but there s hardly any. [rejected: backshifted]
(b) Focus on original
If the focus is on the original utterance (or belief), and there is a contrast between 'then' and 'now', then the backshifted version is favored.
Consider the backshifted sentence
I thought it was mine.
One context for this is where it has just been established that it is
mine: thought would here be strongly stressed, indicating a contrast
between past thinking and present knowing (of the same proposition).
Another context is where it has just been established (or claimed)
that it is not mine: here the contrast is between what I thought in the past and what is known/claimed in the present.
(c) Present perfect reporting clause
Because the present perfect focuses on the present rather than the past, it tends to favor the non-backshifted version. So for example we'd have
She said she couldn't afford it.
But if instead we use the present perfect, we are more likely to drop the backshift:
She has said she can't afford it.
Where the original utterance or belief is in the present tense, the
backshifted and non-backshifted versions differ merely in primary
tense, preterite vs present. But where the original is in the simple
preterite they differ as preterite perfect vs simple preterite, i.e. as
compound vs simple tense. In this case the non-backshifted version may
be preferred precisely for its greater simplicity.