How to know if a reaction forms H3O+ ions or OH- ions?
H3O+ is just the combination of a a $\ce{H+}$ ion, which we know to be released from the dissociation of an acid in an aqueous solution, with a water molecule. It happens because the $\ce{H+}$ is so, so positive (and therefore so reactive) that the water molecules, with its lone pairs (which are locally negatively charged), are willing to form a dative covalent bond with the $\ce{H+}$ ion.
So like Ivan said, whenever you see an acid in an aqueous solution you can consider $\ce{H+ \equiv H3O+}$. The key there though, is that it must be in aqueous solution so that it can dissociate (and the $\ce{H3O+}$ form in the first place). That is the condition that is needed to form it. This is the same for $\ce{OH-}$, which requires an aqueous solution to form and thus release the ions in say NaOH, forming $\ce{Na+}$ and $\ce{OH-}$.