$S_3$ is generated by an element $\tau$ of order three and an element $\sigma$ of oreder two, say $\tau=(1\,2\,3)$ and $\sigma=(1\,2)$, that is every element of $S_3$ can be written as some product of $\tau$s and $\sigma$s, for example $(2\,3)=\tau^2\sigma$. Thus if $f\colon S_3\to G$ is a homomorphism and we know $f(\tau)$ and $f(\sigma)$ then we already know $f$ completely, for example $f(\tau^2\sigma)=f(\tau)f(\tau)f(\sigma)$. However, we cannot pick arbitrary elements of $G$ as images $f(\sigma)$ and $f(\tau)$. First of all, $\sigma^2=1$ implies that $f(\sigma)^2=1$, similarly $f(\tau)^3=1$, i.e. we may pick as $f(\sigma)$, $f(\tau)$ only elements that have the same order as $\sigma$ and $\tau$, respectively, or a divisor of that order. Also, $\sigma\tau=\tau^2\sigma$, so we must also make sure that $f(\sigma)f(\tau)=f(\tau)^2f(\sigma)$, i.e. any relation that holds for $\sigma,\tau$ must also hold for their images.
As it turns out, the relations $\sigma^2=\tau^2=1$ and $\sigma\tau=\tau^2\sigma$ completely determine the group law of $S_3$.
What does this tell us if $G=\mathbb Z/8\mathbb Z$? Here, $G$ has no elements of order $3$, thus $3\cdot f(\tau)=0+8\mathbb Z$ (note that we are using additive notation in $\mathbb Z/8\mathbb Z$) can only be achieved if $f(\tau)=0+8\mathbb Z$. And for $f(\sigma)$ we have only the choices $0+8\mathbb Z$ and $4+8\mathbb Z$ because we need $2\cdot f(\sigma)=0+8\mathbb Z$. Both turn out to be valid choices, which can be verified manually - or one uses the indented paragraph above and checks that the third relation is also respected by (both) $f$.