If $G\cong G/H$ implies $H$ is trivial then $G$ is called *Hopfian*. Otherwise, $G$ is called (imaginatively!) *non-Hopfian*. Non-Hopfian-ness is a truly nasty property!

A related property is that of Residual finiteness. A group is residually finite if for any two elements $g, h\in G$ there exists some homomorphism, $\phi$, to a finite group $H$, $\phi:G\rightarrow H$ such that $\phi(g)\mathrel{\neq_H} \phi(h)$. Equivalently, noting that $\phi(gh^{-1})=1$, $G$ is Residually finite if for any $g\in G$ there exists some $\phi:G\rightarrow H$, $H$ finite, such that $\phi(g)\mathrel{\neq_H} 1$. Note that a finite group is clearly residually finite, and the proof that a finite group is Hopfian is low-level.

It is interesting to note that if $G$ is finitely generated and non-Hopfian then $G$ is not Residually finite. A proof of this can be found in many/most graduate-level texts which cover infinite groups (for example, D. J. S. Robinson's book *A Course in the Theory of Groups*), or see this Math.SE answer. As has been pointed out in the comments below, this only holds if $G$ is finitely generated. For example, the free group on countably many generators is residually finite but is non-Hopfian.

As Joseph Cooper pointed out in his answer, certain Baumslag-Solitar groups are non-Hopfian, such as $$BS(2, 3)\cong \langle a, b;b^{-1}a^2b=a^3\rangle$$ (to see this, take the map $a\mapsto a^2, b\mapsto b$ and play around with it for a bit - it has non-trivial kernel, but the proof is non-trivial...you can find a proof in Magnus, Karrass and Solitar's book *Combinatorial Group Theory*, in their section on one-relator groups, or in this Math.SE answer). Indeed, there exists a classification of the Baumslag-Solitar groups with respect to their Hopficity and Residual-finiteness. Specifically,

The group $BS(m, n)=\langle a, b; b^{-1}a^mba^{n}\rangle$ for $m, n\in\mathbb{Z}$ is,

Residually finite if and only if $|m|=|n|$ or $|m|=1$ or $|n|=1$,

Hopfian if and only if it is Residually finite *or* the set of prime divisors of $m$ is equal to the set of prime divisors of $n$.

So, for example, taking $m$ and $n$ to be coprime and each of absolute value greater than $1$ will yield a non-Hopfian group. There is a paper of Meskin which generalises this to groups with with relation where the relation is of the form $uv^mu^{-1}v^n$ where $u, v$ are words in the generators. Indeed, his statement about residual-finiteness is identical to the case of the Baumslag-Solitar groups ($G$ is residually finite if and only if $m$ and $n$ are equal to each other or one in absolute value). **Edit:** I believe that Meskin's result on residual finiteness was the original result. That is, he proved the general case where the relation has the form $uv^mu^{-1}v^n$ and as a corollary got the first proof of the Baumslag-Solitar case.

Also, the fact that some Baumslag-Solitar groups are not Hopfian is surprising, as the Baumslag-Solitar groups are the $HNN$-extensions of $\mathbb{Z}$, and one would think that an extension of $\mathbb{Z}$ would be very nice indeed! However, that is clearly not the case...

(Note that Chris Leary asked only a few days ago what the history of Hopfian groups was - see here.)