Let $G$ be a finite $p$group, $p$ odd, and let $A$ be a maximal elementary abelian normal subgroup of $G$. Assume that $x \in G$ centralizes $A$ and $x^p$ is a central element. Is it true that $x \in AZ(G)$?.
I don't think so. I can define a group $G = \langle v,w,x,y,z \rangle$ of order $p^5$, with $A = \langle x,y,z \rangle$ elementary abelian, $w^p=z$ and $w \in C_G(A)$ (so my $w$ is your $x$), $v^p=1$, $[v,w]=z$, $[v,x]=y$, $[v,y]=[v,z]=1$. Then $Z(G) = \langle y,z \rangle < A$, so $w \not\in AZ(G)$. (Note that $G$ is a semidirect product of $\langle x,y \rangle \times \langle w \rangle$ by $\langle v \rangle$.) 

