Group With an Endomorphism That is "Almost" Abelian is Abelian.
You don't, as the group is not necessarily abelian! The group of upper triangular 3-by-3 matrices with ones along the diagonal and coefficients in the three-element field $\mathbb {Z}/3\mathbb{Z}$ has exponent three, so your equation holds, but it is not abelian.
There are lots of examples: the most famous ones are the Burnside groups $B(m,3)$: the group I described above is $B(2,3)$.
On the other hand, if the order of your group is not a multiple of 3 then it must be abelian!
You can read a proof here