Let $F=\left \langle a,b \right \rangle$ be the rank 2 free group. Then, a map $f:\left \langle a \right \rangle \rightarrow \left \langle b \right \rangle$ with $f(a):=b$ is an isomorphism with $\left \langle x,f(x) \right \rangle$ is a rank 2 free group for any $x\in\left\langle a\right\rangle - \{ 1\}.$
Can I generalize the situation above? More concretely, let $H\le G$ and $f:H\rightarrow G$ be an injective homomorphism with $H$ isomorphic to $f(H)$. Suppose $\left \langle h,f(h) \right \rangle$ is a rank 2 free group for any $h\in H-H\cap f(H)$ and $f(h)=h$ for $h\in H\cap f(H)$. Then, can we conclude $\left \langle H, f(H)\right\rangle$ is isomorphic to $H *_{H\cap f(H)} f(H)$?
I guess the conjecture above is not generally true when $H$ is non-cyclic. Can I find a nice counterexample?
This does not hold in general. For example, take $G=\langle a, b, c, d; ([a, b][c, d])^2\rangle$. By Magnus' Freiheitssatz for one-relator groups*, $F_A=\langle a, c\rangle$ and $F_B=\langle b, d\rangle$ are free of rank two, and $F_A\cap F_B=1$. This means that $H\ast_{H\cap f(H)}f(H)=H\ast f(H)$ is torsion-free (a free product with amalgamation of torsion-free groups is torsion-free). However, $G$ contains torsion (although it looks it, this is not actually obvious but was proven by Magnus in his thesis*). Therefore, the isomorphism you are after cannot hold.
Hence, we just need to prove that the conditions you require do hold: (1) that there exists an isomorphism $f: F_A\rightarrow F_B$, and that (2) $\langle h, f(h)\rangle$ is free of rank two for $h\in F_A$.
This idea extends to one-relator group with torsion in general. (Condition (2) may be difficult to get to work in general, but Steve Pride proved in the 70s that two-generated subgroups of one-relator groups with torsion are either themselves one-relator groups with torsion, or are the free product of two cyclic groups.)
*see Combinatorial group theory by Magnus, Karrass and Solitar, or Combinatorial group theory by Lyndon and Schupp.
** To illustrate this better, suppose we had taken $X=\langle a, b\rangle$ and $Y=\langle c, d\rangle$. Then $\langle [a, b], [c, d]\rangle$ is not free of rank two as it contains a torsion element.