I'd like to ask for some checking on my solution.
Since $f$ is not surjective, there exists $p \in S^n$ such that for all $x \in X, f(x) \neq p$.
Define $F: X \times I \to S^n$ to be:
$$ \begin{cases} F(x,t) = f(x) & x \in X, 0 \leq t < 1 \\ F(x,1) = p \end{cases}$$
I want to show that this is the homotopy that we need. Clearly $F$ satisfies the condition that $F(x,0) = f(x) \text{ and } F(x,1) = p$. So I just need to show that it's continuous.
Let $U \subset S^n$ be open. It's here that I'm a bit hesitant since I need to distinguish between two cases.
Case 1: $p \in U$. Since $f$ is continuous, we have that $f^{-1}(U)$ is open in X, and so $\pi_X^{-1}(f^{-1}(U))$ is open in $X \times I$, where $\pi_X: X \times I \to X$ is the projection onto $X$. And so $f^{-1}(U) \times [0,1] = \pi_X^{-1}(f^{-1}(U))$ is open in $X \times I$.
Now $F(\pi_X^{-1}(f^{-1}(U)))= F(f^{-1}(U) \times [0,1) \cup f^{-1}(U) \times \{1\}) = f(f^{-1}(U)) \cup \{p\} = U \cup \{p\} = U$. So indeed $F = \pi_X \circ f$, and so $F^{-1}(U) = \pi_X^{-1}(f^{-1}(U))$ is open in $X \times I$ and we are done.
Case 2: $p \notin U$. A similar argument as above would work if we had $\pi_X^{-1}(f^{-1}(U)) = f^{-1}(U) \times [0,1)$ (instead of $f^{-1}(U) \times [0,1]$), but I don't see how we can have that.
Also why do we need $f$ to be surjective here?
====================================================================
Edit: it's been pointed out to me that the function $F$ that I defined is not continuous. Could this be the reason why I ran into the problem in the second case?
The $F$ that you defined is not continuous.
Since $f$ is not surjective, consider the stereographic projection $H$ centered at $p$ which is not in the image of $f$ and define:
$G(t,x)=H^{-1}(tH(f(x))$.