If there is a contradiction between something the Rambam wrote in the Mishneh Torah and his responsum letters, which is considered his final ruling? Is there a general rule or is it a case by case?
Great question. It's a problem that is not limited to the Rambam, you can find the same phenomenon among other poskim.
For example, the Maharil "contradicts" himself regarding when one removes shoes before the Ninth of Av. Does one take them off at home, or before Ma'ariv? That depends whether you read the responsa or the "Customs" (מנהגי מהרי"ל). See here: http://hebrewbooks.org/pdfpager.aspx?req=8859&st=&pgnum=111
Here is a series of shiurim that covers the issue: