The actor, who was killed off in the Caribbean detective drama at the start of the most recent series, will appear opposite Peter Capaldi in the new series of the long-running science-fiction show this autumn.
He said: "As a committed Whovian I cannot believe my luck in joining the 12th Doctor for one of his inaugural adventures. My only worry is that they'll make me leave the set when I'm not filming."
Miller's comedy partner Alexander Armstrong has already appeared in the show playing Reg Arwell in the 2011 Christmas Special.
The show's executive producer Steven Moffat said: "Mark Gatiss has written us a storming villain for his new episode, and with Capaldi in the Tardis, we knew we needed somebody special to send everybody behind the sofa. And quite frankly, it's about time Ben Miller was in Doctor Who."