The melting point is related to the strength of the bond, the higher the bond strength, the higher the melting point of the compound. The strength of ionic bonds usually depends on two factors 1) ionic radius and 2) charge.
In MgO, magnesium has a charge of +2 and in K2O, potassium has a charge of +1, so higher charge implies higher bond strength.
The answer is MgO has the higher melting point