There's no real difference to me, both sentences imply that the last time I spoke to him was 3 years ago. But if I had to think of a difference, I would say that "for" puts more emphasis on the entire period of 3 years (taken as a whole), while the sentence with "in" implies that there hasn't been a single time in the last three years that I've talked to him.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.