In order to find the number of moles of O2 in this reaction we need to set up the properly balanced equation, which the question already gave us:
2 HgO -> 2 Hg + O2
From this equation we see that the molar ratio between HgO and O2 is 2:1, which means that for every 2 moles of HgO reacting we will end up having 1 mol of O2 as product, now what if we have 3.4 moles of HgO:
2 HgO = 1 O2
3.4 HgO = x O2
x = 1.7 moles of O2