Let $\scr A$ be a structure generated by $S$, then every homomorphism $\pi: \scr A \to \scr{B}$ is determined by its value on $S$.
Proof:
Let $\pi '$ be another homomorphism, then $C=\{b: \pi (b)= \pi '(b) \}$ is either empty or a substructure. If $\pi$ and $\pi'$ coincide on $S$, then $S\subseteq C$ and hence $C=A$.
I am not sure I see that $C$ is a substructure, if it's not empty?
The rest I understand, if $\pi=\pi '$ for each $s$ in $S$, then $S$ is a subset of $C$ since the two functions are homomorphisms.
[It also follows that $C\subseteq S$. So, $C=A$.] This is wrong, as Mr. Alex Kruckman pointed out
Since $S\subseteq C$ and $\scr A$ is generated by $S$, then $A$ must be $C$;
Let $C = \{b : \pi(b) = \pi'(b)\}$ where $\pi, \pi' : \mathcal{A} \to \mathcal{B}$ are two homomorphisms betweeen structures $\mathcal{A}$ and $\mathcal{B}$ (over some signature $\Sigma$). Then $C$ is either empty or a substructure of $\mathcal{A}$, because if $c_1, \ldots, c_n \in C$ then so is $f(c_1, \ldots, c_n)$ for any $n$-ary function symbol $f$ in $\Sigma$. (It follows as you state in the question that if $\pi$ and $\pi'$ agree on a set $S$ of generators for $\mathcal{A}$, then $\pi = \pi'$.)
A few comments are in order: