7 answers
(click or scroll down)
You can do it one of several ways.
1. Look at the periodic table. Mg is in group II. Mg is +2.
2. Look at the sulfate ion. If you've written very many formulas you know sulfate (SO4^2-) is -2. Since all compounds are zero charge, then Mg must be +2 to balance the -2 of sulfate.
3. S is in group VI. It is +6 (but you can't use this every time for S because S can be +4 and -2 as well as some oathers). O is -2 and there are four of them for -8 total. -8 from O and +6 from S means sulfate must be -2. Then Mg must be +2.