When we burn magnesium, the following reaction takes place:
Mg reacts with O2 to form magnesium oxide.
When the magnesium is heated up, the total mass increases because magnesium reacts with oxygen, forming magnesium oxide. Then, we could say that the product formed during the combustion of magnesium weights more than the original piece of magnesium.
Magnesium oxide has the formula of MgO according to the ratio between the moles of magnesium and oxygen in the final product.