When a metal combines with oxygen metallic oxides are formed and they are generally basic in nature. This is due to the fact that when they react with water, they produce basic compounds.
Metals tend to lose their electrons, as they have very low ionization potential (energy required to remove an electron from the outermost shell) and the easier they lose their electron, the more metallic nature they dwell.
The more metallic they are, the more basic oxides they form.
Since Sodium (Na) has a larger atomic size than Magnesium (Mg), it has lower ionization potential, which means it is more metallic. Hence it could be stated that Na2O is more basic than MgO.