Interesting question - ignoring what he's contracted to do, I think that leaving in less than 3 years would look ungrateful. He's not got a family, at the moment, so the filming schedule isn't as hard on him as it would be an actor with children. But I think typecasting could be a tough problem for him, partly because it is for all actors in the role, partly because he didn't have lot of well known roles before that (and hope that doesn't sound like I'm undervaluing his work before this, just talking about how famous he was), and partly because going on interviews so far, and this may just be my perception, he seems to be playing the Doctor quite close to his own personality, which is great for people believing in his doctor but tougher for people to accept him as something completely different in other things. I think he'll get bored after three or four years.
Of course it could depend on how long Moffat stays. How long will he want to be showrunner? How long before he's written out? A new showrunner would probably want a year maximum of Smith and then get their own doctor in. I can't see Moffat doing much longer than RTD.