What OP is classifying with $\pi_2 (G)$ [where the gauge group here is $G=U(1)$], is the globally$^1$ defined gauge transformations $g: M\to G$. This is typically not what we want to calculate.
When discussing the Dirac monopole physicists are instead interested in classifying inequivalent configurations of the dynamical variable of the theory, i.e. the gauge potential $A$. More precisely, in the Wu-Yang/bundle picture (which avoids the use of a Dirac string), we consider the associated vector bundle $$T^{*}M\otimes \mathfrak{g}~\to~ M,$$ where $\mathfrak{g}=\mathfrak{u}(1)$ is the corresponding Lie algebra. It is implicitly understood that the gauge potentials $A_{\alpha}: U_{\alpha}\to \mathfrak{g}$ are defined on local charts $U_{\alpha}\subset M$ with $\cup_{\alpha}U_{\alpha}=M$. Moreover it is implicitly understood that two local sections $A_{\alpha}: U_{\alpha}\to \mathfrak{g}$ and $A_{\beta}: U_{\beta}\to \mathfrak{g}$ are connected via local gauge transformations $g_{\alpha\beta}: U_{\alpha}\cap U_{\beta} \to G$ in the overlaps $U_{\alpha}\cap U_{\beta}$.
It turns out that we are therefore interested in counting maps from the equatorial overlap region $S^1$ to $G$, i.e. $\pi_1 (G)$, as twistor59 explains in his answer.
--
$^1$ The underlying space manifold for the Dirac monopole is $M=\mathbb{R}^3\backslash\{\bf 0\}$, which is homotopy equivalent (but not homeomorhic) to $S^2$. We have removed the origin, since the Dirac monopole is singular there. [The 't Hooft-Polyakov monopoles are regular in the full space $\mathbb{R}^3$, but we will not discuss these monopoles in this answer.]