Let $M$ be a closed, smooth, orientable $n$-manifold. How do I see that every class in $H_{n - 1}(M; \mathbb{Z})$ (resp. $H_{n - 2}(M; \mathbb{Z})$) is represented by a closed, smooth, orientable submanifold of codimension $1$ (resp. $2$)?
Thoughts. Perhaps we want to use the fact that $S^1$ is a $K(\mathbb{Z}, 1)$ (resp. $\mathbb{C}P^\infty$ is a $K(\mathbb{Z}, 2)$) and represent a cohomology class by a smooth map, then use general position?
Your approach is the right one, as also mentioned in the comments. Let me spit out some details:
$H_{n-1}(M;\mathbb Z)$ isomorphic to $H^1(M;\mathbb Z)\cong [M,K(\mathbb Z,1)]=[M, S^1]$. Now given $f:M\rightarrow S^1$, take a regular value p, and check that $[f^{-1}(p)]$ is the required homology class.
The story for codimension $2$ is very similar. Then $H_{n-2}(M;\mathbb Z)$ corresponds to $H^2(M,\mathbb Z)\cong [M,K(\mathbb{Z},2)]= [M,\mathbb{CP}^\infty]$. Now $\mathbb{CP}^\infty$ is not a manifold, so we can't use general position directly. However, it can be well approximated by manifolds, which is enough:
By cellular approximation, any map $M\rightarrow \mathbb{CP}^\infty$ can be homotoped to a map into $\mathbb{CP}^{\dim M}$. Now $\mathbb{CP}^{\dim M-1}\subset \mathbb{CP}^{\dim M}$, and up to homotopy, $f$ will meet $CP^{\dim M-1}$ transversely. Check that $f^{-1}(\mathbb{CP}^{\dim M-1})$ represents the right homology class.
For higher codimension homology classes the story along these lines ends here I believe. However Thom investigated this problem in general, and gave more answers (certain multiples of homology classes can be represented by submanifolds, but generally this does not work. Over $\mathbb{Z}/2\mathbb{Z}$ it is always possible)