The Hamiltonian operators is always something that comes from the energy in the system. Ask the class if they remember what the energy in the systems found in the Stern-Gerlach experiment.
If students do not give the expression right away, ask, “what about the atom is causing there to be an energy?” Typically a student will mention the magnetic moment or magnetic field. If only one is given, ask the class if they remember the other and how the two make up the energy expression.
Write down on the board
$$H=- \: \vec{\mu} \cdot \vec{B}=- \: \gamma \, \vec{S} \cdot \vec{B} \; \; .$$
Note to the class the process of changing the classical energy to the operator is not always simple, but in this case we know that $\vec{S}$ is an operator. So, we denote the operators with hat symbols ^.
If we look at the case where $\hat{\vec{S}}=\hat{S_{z}} \, \hat{i}$ and $\vec{B}=B_{z} \, \hat{i}$, the Hamiltonian operator is
$$\hat{H}=- \: \gamma S_{z} B_{z} \; \; .$$
Although this Hamiltonian isn't very interesting because it is proportional to an operator we already know ( $\;S_{z}\;$ ) and because it depends on the magnitude of the external magnetic field, it is a very useful operator. The eigenvalues of the matrix for the Hamiltonian will be the energy values that you can measure. Note that the difference in the energy eigenvalues is more important than the values themselves since we are more commonly interested in the difference of energy levels.
Now, ask students what the eigenvalues of the Hamiltonian are in the spin-$\frac{1}{2}$ system. If students struggle to find the answer, remind them that $\hat{H}$ is proportional to $\hat{S_{z}}$. Eventually, the answer
$$\pm \gamma B_{z} \frac{\hbar}{2}$$
should be found.