Here is a completion of the proof in Andy's answer. One needs to show that the subgroup is finitely generated (which is not true if $G$ is not finitely presented). The subgroup (also called the Mihailova subgroup) is generated by the elements $(a,a)$ and $(1,r)$, where $a$ runs over the generators of $F(S)$ and $r$ runs over the finite set of defining relations of $G$. The fact that the Mihailova subgroup (it consists of all pairs $(x,y)$ with $f(x)=f(y)$) is generated by these elements is easy. Clearly for every generator $(u,v)$ ($u=v=a$ or $u=1, v=r$) we have $f(u)=f(v)$. Conversely, if $f(u)=f(v)$, that is $f(uv^{-1})=1$ in $G$, the word $uv^{-1}$ can be represented as a product of conjugates of defining relators and their inverses. From this product it is easy to represent the pair $(u,v)$ as a product of generators (see, for example, this paper and the references there). For example, if $uv^{-1}=ara^{-1}$, then $(v,u)=(a,a)(1,r)(a,a)^{-1}(v,v)$ where $(v,v)$ is an obvious products of pairs of the form $(a,a)$.