Indeed, there is the said surjection:
a map from $\, S^1\, $ into $\,X\,$ with a disk attached
can be homotopically moved in such a way that the image of $\,S^1\,$ will end up in $\,X\, $ (where $\, X\, $ is interpreted here as a subset of $\, X\,$ with a disk attached to it). And the points of the circle which were originally mapped into $\,X\, $ don't even have to move during the homotopy.
Here is a pretty detailed proof:
But first a remark,
Remark: We may assume that the base point $\,x_0\,$ belongs to
$\,f(S^1).\,$ Then the case of arbitrary $\,x_0\,$ which belongs
to $\,X\,$ follows (well, to the canonical image of $X$).
Furthermore, we may assume that the same $\,x_0\,$ is a base point
of $\,S^1.$
Warning: There are points of $\,S^1\,$ just as (kind of abstract) $\,S^1.\, $ And there are points of $\,f(S^1).\,$ Keep them separated
in your mind, there is nothing to worry.
Proof:
Let $\,\Bbb C\, $ be the field of the complex numbers,
$\,D:=\{z\in\Bbb C: |z|\le 1\},\,$ $\,B:=\{z\in\Bbb C: |z|\le \frac12\},\,$
$\,S_B:=\{z\in\Bbb C: |z| = \frac12\},\,$ and $\,T:=f^{-1}(B).$
Let $\,g:S^1\to X\cup_f D\,$ be an arbitrary continuous loop for which
$\,g(x_0)=x_0.$
There is continuous $\, h_0: g^{-1}(B)\to X\cup_f D\, $ such that
$\,h_0(g^{-1}(B))\subseteq S_B\, $ and $\,h_0(x)=g(x)\,$ whenever
$\,g(x)\in S_B\,$ -- this is so because $\,\dim(g^{-1}(B))=1.$
Also, $\,\, g|((X\cup_f D\setminus B)\cup S_B)\,:\,
(X\cup_f D\setminus B)\cup S_B\, \to\, X\cup_f D\,\,$ is continuous.
Also, the join extension $\,\,h:S^1\to X\cup_f D\,\, $ of functions
$\,\,g|((X\cup_f D\setminus B)\cup S_B)\,$ and $\,h_0\,\,$ is
continuous. Obviously, $\,g\,$ and $\,h\,$ are homotopic under which
$\,x_0\,$ is fixed all the time (from $0$ to $1$).
Finally, define $\,\ell:S^1\to X\cup_f D\,$,
$$ \forall_{x\in h^{-1}((X\cup_f D)\setminus(D\setminus S^1))}
\quad \ell(x)=h(x) $$
and
$$ \forall_{x\in D\setminus S^1}\quad \ell(x)\,=\,
f\left(\frac {h(x)}{|h(x)|}\right) $$
(recall that above, $\,|h(x)|\ge\frac12.)$
Once again, $\,\ell\,$ and $\,h\,$ admit a homotopy under which
$\,x_0\,$ is fixed. Thus the same is true for $\,g\,$ and $\,\ell.\,$
But
$$ \ell(S^1)\,\subseteq\,X $$
(assuming one of the equivalent constructions for which
$\,X\subseteq X\cup_f D,\,\,$ i.e.
$\, X\,=\,(X\cup_f D)\setminus(D\setminus S^1)\,\,) $
The theorem has been proven. Great!
Best Answer
The point is that, even if two classes $[f]$ and $[g]$ are different in $\pi_1(X,x_0)$ (that is, $f$ and $g$ are not homotopic in $X$), it can be the case that $[f]=[g]$ in $\pi_1(Y,x_0)$ (when $f$ and $g$ are homotopic in $Y$).
Indeed, when you write "$i_*([f])=[f]$" (which is true!), the "$[f]$" on the left side is different from the "$[f]$" on the right side, even if you write them with the same symbol: the one on the left side is the class of the loops (on $x_0$) homotopic (relatively to $x_0$) to $f$ in $X$, while the one on the right side is the class of the loops homotopic to $f$ in $Y$.
For instance, consider the inclusion $i$ of $D\setminus \{p\}$ into $D$, being $D$ a disk and $p$ one of its points. Let $f$ be a loop on a fixed $x_0 \in D\setminus \{p\}$ such that $f$ goes around $p$. Then clearly $[f]\neq[\sigma_{x_0}]$ in $\pi_1(D\setminus \{p\})$, but of course $[f]=[\sigma_{x_0}]$ in $\pi_1(D)$. Here $\sigma_{x_0}$ denotes the constant loop on $x_0$. Hence in this case $i_*$ is not injective. And indeed $D\setminus \{p\}$ is not a retract of $D$!
Edit. I rewrite everything with the clarifying notation.
The point is that, even if two classes $[f]_X$ and $[g]_X$ are different in $\pi_1(X,x_0)$ (that is, $f$ and $g$ are not homotopic in $X$), it can be the case that $[f]_Y=[g]_Y$ in $\pi_1(Y,x_0)$ (when $f$ and $g$ are homotopic in $Y$).
Indeed, when you write "$i_*([f]_X)=[f]_Y$" (which is true!), the "$[f]_X$" on the left side is different from the "$[f]_Y$" on the right side: $[f]_X$ the one on the left side is the class of the loops (on $x_0$) homotopic (relatively to $x_0$) to $f$ in $X$, while $[f]_Y$ is the class of the loops homotopic to $f$ in $Y$.
For instance, consider the inclusion $i$ of $D\setminus \{p\}$ into $D$, being $D$ a disk and $p$ one of its points. Let $f$ be a loop on a fixed $x_0 \in D\setminus \{p\}$ such that $f$ goes around $p$. Then clearly $[f]_{D\setminus\{p\}}\neq[\sigma_{x_0}]_{D\setminus\{p\}}$ in $\pi_1(D\setminus \{p\})$, but of course $[f]_D=[\sigma_{x_0}]_D$ in $\pi_1(D)$. Here $\sigma_{x_0}$ denotes the constant loop on $x_0$. Hence in this case $i_*$ is not injective. And indeed $D\setminus \{p\}$ is not a retract of $D$!