Existence of non-null-homotopic map from $M^n$ to $S^{n-1}$ Let $M^n$ be compact, connected, oriented $n$-dimensional smooth manifold without boundary, the Hopf degree theorem states that the homotopy class of continuous maps from $M^n$ to $S^n$ is classified by its degree. What about continuous map from $M^n$ to $S^{n-1}$ (assume $n>0$) ? I am mostly interested in the case $n>2$.
More specially, when does there exist a non null-homotopic map in the case $n=3$? If $H^2(M,\Bbb Z) \not=0$ then it's true as $[M,\Bbb{C}P^{\infty}]=H^2(M,\Bbb Z)$ and $\Bbb CP^1 \cong S^2$. This is not necessary as $M=S^3$ shows.
 A: 
Theorem. If $M$ is a compact connected oriented $3$-manifold, then there is always a homotopically non-trivial map $f:M\to \mathbb{S}^2$.

Proof. Let $g:M\to\mathbb{S}^3$ be a map of degree one. Such a map always exists and it is not homotopic to a constant map. 
Existence of $g$: take a small ball $B$ in $M$ that is diffeomorphic to a Euclidean ball. Map the ball $B$ diffeomorphically in an orientation preserving way onto $\mathbb{S}^3$ so that the boundary of the ball is mapped to a south pole. Map the complement $M\setminus B$ to the south pole. This map is continuous, but one can make it smooth (smoothing argument). The degree of the map is $1$ as it follows from the definition of the degree as the sum of signs of the Jacobian at the preimage. Clearly $g$ is not homotopic to a constan map, because degree is a homotopy invariant.
Let $h:\mathbb{S}^3\to\mathbb{S}^2$ be the Hopf fibration. Then the map $f=h\circ g:M\to\mathbb{S}^2$ is not homotopic to a constant  map. Indeed, suppose that $H:M\times [0,1]\to \mathbb{S}^2$ is a homotopy between $H(\cdot,0)=f$ and a cosntant map $H(\cdot,1)$. According to Proposition 4.48 in Hatcher's Algebraic Topology, the Hopf fibration has the homotopy lifting property so the homotopy $H$ can be lifted to $\tilde{H}:M\times [0,1]\to \mathbb{S}^3$. That is $\tilde{H}(\cdot,0)=g$ and $\tilde{H}(\cdot,1)$ is a lift of a constant map into some point $p$ i.e., it is a map into the fiber $h^{-1}(p)=\mathbb{S}^1$. Since $\mathbb{S}^1\subset\mathbb{S^3}$ is contractible, the map $\tilde{H}(\cdot,1)$ is homotopic to a constant map. Hence also $\tilde{H}(\cdot,0)=g$ is homotopic to a constant map which is a contradiction.
EDIT. I added some details following comments from:  Neil Strickland,  Andreas Blas and Dan Petersen.
A: For $n=3$, there are good general results about $[X,S^2]$ and $[X,S^3]$ (for arbitrary spaces $X$) in the paper The principal fibration sequence and the second cohomotopy set by Laurence Taylor.
For $n\geq 4$ I claim that there is an exact sequence
$$ H^{n-2}(M;\mathbb{Z}) \xrightarrow{\text{Sq}^2\circ\rho} H^n(M;\mathbb{Z}/2) \simeq\mathbb{Z}/2 \to [M,S^{n-1}] \to H^{n-1}(M;\mathbb{Z}) \to 0 $$
The first map here is the composite of the reduction map $\rho\colon H^{n-2}(M;\mathbb{Z})\to H^{n-2}(M;\mathbb{Z}/2)$ with the Steenrod operation $\text{Sq}^2\colon H^{n-2}(M;\mathbb{Z}/2)\to H^n(M;\mathbb{Z}/2)$.  It could be analysed further using the universal coefficient theorem and the theory of Wu classes, but I will not go into that here.
To prove the claim, standard calculations show that for $n\geq 4$ we have $\pi_{n-1}(S^{n-1})=\mathbb{Z}\iota$ and $\pi_n(S^{n-1})=\mathbb{Z/2}\eta$ and $\pi_{n+1}(S^{n-1})=\mathbb{Z}/2\eta^2$.  Also, the homotopy groups of the connective real $K$-theory spectrum $kO$ are $(\mathbb{Z}\iota,\mathbb{Z}/2\eta,\mathbb{Z}/2\eta^2,0,\dotsc)$.  Now let $B$ be the $(n-1)$'th space in the $\Omega$-spectrum for $kO$, so $[X,B]=kO^{n-1}(X)$ for all spaces $X$.  Let $F$ be the fibre of the unit map $S^{n-1}\to B$.  From the long exact sequence of the fibration we find that $\pi_i(F)=0$ for $i\leq n+1$.  By induction over the cells of $X$, we deduce that the map $[X,S^{n-1}]\to [X,B]$ is bijective whenever $X$ is a CW complex of dimension at most $n$.  In particular, we can take $X=M$ to see that $[M,S^{n-1}]=kO^{n-1}(M)$, so we now have a calculation in stable homotopy theory. 
I will formulate the rest of the argument in terms of the Atiyah-Hirzebruch spectral sequence, but it could be reformulated in terms of obstruction theory if desired.
The spectral sequence has the form
$$ E_2^{pq} = H^p(M;kO^q) \Longrightarrow kO^{p+q}(M), $$
with differentials $d_r\colon E_r^{pq}\to E^{p+r,q-r+1}$.  Here $kO^q$ is the same as $\pi_{-q}kO$, so it is trivial unless $q\leq 0$, so the spectral sequence is concentrated in the fourth quadrant.  Also, the cohomology of $M$ is concentrated in degrees zero to $n$, so the spectral sequence is concentrated in columns zero to $n$.  The target group $kO^{n-1}(M)$ has a filtration with quotients $E_\infty^{p,n-1-p}$.  The only possible nonzero terms are $E_\infty^{n-1,0}$ (which is a subquotient of $E_2^{n-1,0}=H^{n-1}(M;\mathbb{Z})$) and $E_\infty^{n,-1}$ (which is a subquotient of $E_2^{n,-1}=H^n(M;\mathbb{Z}/2\eta)$).  We therefore have a short exact sequence 
$$ E_\infty^{n,-1} \to kO^{n-1}(M) \to E_\infty^{n-1,0} $$
Now recall that $d_r$ has bidegree $(r,1-r)$.  It follows that all differentials starting at $(n-1,0)$ or $(n,-1)$ have endpoint in the region $p>n$ where the spectral sequence is zero.  Similarly, all differentials ending at $(n-1,0)$ or $(n,-1)$ have starting point in the region $q>0$ where the spectral sequence is zero, with the exception of the differential
$$ d_2\colon H^{n-2}(M;\mathbb{Z}) = E_2^{n-2,0} 
    \to E_2^{n,-1} = H^n(M;\mathbb{Z}/2\eta).
$$
Thus, $E_\infty^{n,-1}$ is the cokernel of the above differential, whereas $E_\infty^{n-1,0}$ is just the same as $E_2^{n-1,0}=H^{n-1}(M;\mathbb{Z})$.  By considering the Posnikov tower of $kO$, one can also check that the nontrivial differential is the composite of the reduction map $\rho\colon H^{n-2}(M;\mathbb{Z})\to H^{n-2}(M;\mathbb{Z}/2)$ with the Steenrod operation $\text{Sq}^2\colon H^{n-2}(M;\mathbb{Z}/2)\to H^n(M;\mathbb{Z}/2)$.
A: First, this paper of Kirby, Melvin and Teichner (which I haven't completely digested) discusses the case of maps from smooth, closed, connected, oriented 4-manifolds $M$ to $S^3$. Theorem 1 is a refinement of the following: $[M,S^3]$ is an abelian group with a surjective homomorphism to $H_1(M)$ which is either an isomorphism or a two-to-one epimorphism, depending on whether $M$ contains at least one closed oriented surface of odd self-intersection ($M$ is "odd") or if no such surface exists ($M$ is "even").
What follows is an elaboration on the case of 3-manifolds, already treated by Piotr Haljasz.
The beginning of Section 3 of this paper of DeTurck, Gluck, Komendarczyk, Melvin, Shonkwiler, and Vela-Vick discusses the homotopy classification of maps from oriented closed smooth 3-manifolds to $S^2$ (originally due to Pontryagin). 
To summarize, homotopy classes of maps from $M$ to $S^2$ (elements of $[M,S^2]$) are classified by two invariants. First, the primary invariant  $\lambda(f)\in H_1(M,\mathbb{Z})$ is the homology class of the inverse image $f^{-1}(\ast)$ for any regular value $\ast$ of $f$ (and $\lambda(f)$ can take any value in $H_1(M,\mathbb{Z})$). The secondary invariant $\nu(f_0,f_1)\in\mathbb{Z}_{2d(\lambda)}$ compares two maps $f_0,f_1$ with the same primary invariant $\lambda$, where $d(\lambda)$ is the divisibility of $\lambda$ as an element of $H_1(M,\mathbb{Z})/\text{torsion}$, i.e. $d(\lambda)=0$ if $\lambda$ is of finite order and otherwise equal to the largest positive integer $d$ such that $d\lambda=\kappa$ for some $\kappa\in H_1(M,\mathbb{Z})$. Again, $\nu(f_0,f_1)$ can take on all values in $\mathbb{Z}_{2d(\lambda)}$.
This classification gives us an infinite number of homotopically nontrivial maps to $S^2$: in particular, the maps with $\lambda=0$ are in bijection with $\mathbb{Z}$.
In the language of the above invariants, Piotr Hajlasz's answer constructs a map $f=h\circ g$ with $\lambda(f)=0$ and $\nu(\text{const}, f)=1$ (where "const" is a constant map $M\rightarrow S^2$) and proves that it is not nullhomotopic.
As an aside: the Pontryagin-Thom theorem states that homotopy classes of maps from $M$ to $S^2$ are in bijection with bordism classes of framed links in $M$ and this turns out to be a beautiful and powerful way of visualizing such maps. The two invariants above can be viewed as bordism invariants of framed links: for example, the maps with $\lambda=0$ correspond to bordism classes of the unknot with framing $m$ for all $m\in\mathbb{Z}$. See the discussion in the reference of DeTurck et al and also check out the figures there which illustrate the classification for $M=T^3$.
One ought to be able to apply Pontryagin-Thom to better understand elements of $[M^n,S^{n-1}]$ for any $n$ (they still correspond to bordism classes of framed links in $M$) and I suspect it has been done but I don't know of a reference which does this in general. 
Note that when $n>3$ the framing of the unknot now only takes values in $\mathbb{Z}/2\mathbb{Z}$, essentially because $\pi_1(SO(n-1))\cong\mathbb{Z}/2\mathbb{Z}$, which I discussed at the end of this old MO answer. In the $n=4$ result of Kirby, Melvin and Teichner, this appears in the fact that the kernel of the homomorphism from $[M,S^3]$ to $H_1(M)$ has at most order 2; see the discussion in the subsection "Twisted Classes" on page 165 and also Claim 1.1 in their paper.
