5. Given $z \in \mathbf{C}, a>0$. Then $1-\frac{2 a}{z+a}$ is a pure imaginary number if and only if ( ).
(A) $|z|=a$
(B) $|z|=a$ and $z \neq-a$
(C) $|z|=a$ or $z \neq \pm a$
(D) $|z|=a$ and $z \neq \pm a$
5.D.
$$
1-\frac{2 a}{z+a}=\frac{z-a}{z+a} \text {. }
$$

As shown in Figure 2, let $A(-a, 0)$, $B(a, 0)$, and the point corresponding to the complex number $z$ be $P$, then $AP = z + a$,
$$
\begin{array}{l}
BP = z - a \text {. } \\
\frac{z-a}{z+a} \text { is a pure imaginary number } \\
\Leftrightarrow \arg \frac{z-a}{z+a} = \pm 90^{\circ} \\
\Leftrightarrow \angle APB = 90^{\circ} \\
\end{array}
$$
$\Leftrightarrow$ The locus of the moving point $P$ is a circle with $AB$ as its diameter (excluding points $A$ and $B$)
$$
\Leftrightarrow |z| = a \text { and } z \neq \pm a \text {. }
$$