a) Let e denote the unit of G. Let x=y=z=e to write f(e)3=f(e), so f(e)2=e. Since n is odd, it follows that f(e)=e.
If x and y are members of G, write f(xy)=f(xye)=f(x)f(y)f(e)=f(x)f(y), to conclude that f is indeed an endomorphism of G.
b) The answer is negative. Let a be an order 2 element of G, and let f:G→G, f(x)=a. If x,y,z are elements of G, then f(xyz)=a=a3=f(x)f(y)f(z), so f is a pseudoendomorphism. However, f is not an endomorphism, since f(e)=a=e.