The first-principles methods based on the density functional theory were employed to study the structural stability, segregation and work function of Mg doped with fourteen metal elements existing in human body. The calculated results show that there is a simple correlation between solid solution and segregation. Doping Sn, Y, Li, Gd, Nd, Sc and Zn atoms have a negative formation energy as well as a positive segregation energy. This suggests that these elements which are not easier to be dissolved in Mg matrix tend to segregate on the Mg (0001) surface. An opposite trend was observed for Ba, Fe, Mn, W, Sr, Ca and Mo. On the other hand, the electronic work function of Mg (0001) surface was increased significantly for doping Mo, W, Fe, and Mn, and was reduced markedly for Ba, Ca and Sr. For Li, Sn, Sc, Gd, and Y, their doping on Mg surface generate a relatively small change in work function. In addition, the relationships of corrosion behavior to segregation and work function were discussed. This study may provide an avenue for seeking a more appropriate alloying element of Mg alloys with improved corrosion resistance in biomedical applications.