I was taught a very simple rule around this, if you remove the other person you're referring to, is the sentence still grammatically correct?
So for your example:
> He gave it to Tom and I.
Change it to:
> He gave it to I.
That's clearly weird, so it should actually be:
> He gave it to me.
And then re-incorporating the other person:
> He gave it to Tom and me.
When I see your version in my mind it's a mistake and my theory is it's a common misunderstanding of the rule, consider the following slightly different scenario which is a super common mistake in my experience:
> Me and Tom went to the movies.
That is clearly wrong when applying the rule and should be:
> I and Tom went to the movies.
Although I feel that this sounds better:
> Tom and I went to the movies.
I think that what often happens (at least it did for me) is that children making the above mistake only ever see the correction without being reminded of or taught the actual rule, so they incorrectly assume the rule is something like:
> Always use "I" when talking about yourself and someone else.
I live in South Africa and we use British English, but I would expect the rule to be the same for American English too.