Whenever $ad_{\xi}$ is an endomorphism of $\mathfrak{g}$ whose corresponding partition $\pi: 1^{s_{1}}2^{s_{2}} \cdots \;$ of $\dim \mathfrak{g}$ is such that $s_{1} =0$, then we have $im\; ad_{\xi} \cap Z(\mathfrak{g}) \neq \{0\}$.
As $\mathfrak{g}$ is nilpotent, $ad_{\xi}$ acts as a nilpotent endomomorphism of $\mathfrak{g}$, for every $\xi \in \mathfrak{g}$, and we can associate to $ad_{\xi}$ a partition $\pi(\xi)$ of $n=\dim \mathfrak{g}$ as follows: the Jordan form of $ad_{\xi}$ is
$$J=\begin{bmatrix} J_{1}\\\ & \ddots \\\ && J_{r}\end{bmatrix}$$
where $J_{i}$ is an $n_{i}\times n_{i}$ $0$-Jordan block and $n_{1}\geq \ldots \geq n_{r} >0$. Then, $n_{1} +\ldots +n_{r}=n$ is a partition of $n$, which we will denote $\pi(\xi): 1^{s_{1}}2^{s_{2}} \cdots $, so that $$1s_{1}+2s_{2}+\ldots =n$$ is the partition of $n$ determined by $J$.
Let $\xi \in \mathfrak{g}$ and let $\pi(\xi) : 1^{s_{1}}2^{s_{2}} \cdots $ be the partition associated to $ad_{\xi}$ and suppose that $(x_{1},\ldots,x_{n})$ is a Jordan basis of $ad_{\xi}$, so that the matrix of $ad_{\xi}$ is in Jordan form. Thus, $x_{1},x_{n_{1}+1},\ldots, x_{n_{r-1}+1}$ is a basis of $$Z_{\mathfrak{g}}(\xi)=\ker ad_{\xi}.$$
As $\mathfrak{g}$ is nilpotent we must have $Z(\mathfrak{g}) \neq \{0\}$. Let $w \in Z(\mathfrak{g})$ be nonzero. Then, $w \in Z_{\mathfrak{g}}(\xi)$ and so $w= c_{1}x_{1}+\ldots + c_{r} x_{n_{r-1}+1}$.
Assume that $s_{1}=0$ in the partition $\pi$ (so that $\pi$ contains no parts equal to $1$). Thus, $x_{2},\ldots, x_{n_{r-1}+2} \notin Z_{\mathfrak{g}}(\xi)$ and $x=c_{1}x_{2}+\ldots +c_{r}x_{n_{r-1}+2}$ is such that $[\xi,x] =w\in Z(\mathfrak{g})$.
While this condition is sufficient it is not necessary: for example, consider the nilpotent Lie algebra $\mathfrak{n}_{3}$ of strictly upper triangular $3\times 3$ complex matrices. Then,
$$\xi = \begin{bmatrix} 0&1&0\\\0&0&1\\\0&0&0\end{bmatrix}$$
is such that $im \; ad_{\xi}=Z(\mathfrak{n}_{3})$, while $\pi(\xi): 12$.