In the first example I would go for "He earned an MD and a gold medal from St Andrews", because to leave out the second "a" implies that the gold medal is an enhancement to the MD in the sense of "DSO and bar".
In the second example, however, "He was appointed Consultant Surgeon at Hospital A and Hospital B" is fine, because the first "at" functions in linking both hospitals with "he was appointed Consultant Surgeon".
However, you'd keep both "at"s in if you were going to extend the sentence to say something different about what he was appointed to in Hospital B - "He was appointed Consultant Surgeon at Hospital A, and at Hospital B he was recognised for long service".