With these sort of questions, it's important to firstly think about what type of bonds make up the structure of the element. For this example, they both have metallic bonds which hold the structures together. Now we have to think about which what metallic bonds are and which element has the stronger bonds which will ultimately determine the melting point.
Metallic bonds can be defined as the attraction between positive metal cations and the delocalised electrons which flow through its structure. Sodium will delocalise 1 electron per atom (Na+) and Magnesium will delocalise 2 electrons per atom (Mg2+). Because magnesium has a greater charge, there will be greater attraction between delocalised electrons and the positively charged ions and so more energy will be needed to overcome this attraction. Magnesium will have a higher melting point than sodium.