6. (B)

By Vieta's formulas, we have
$$
\begin{aligned}
x_{1}^{2}+x_{2}^{2}= & \left(x_{1}+x_{2}\right)^{2}-2 x_{1} x_{2} \\
& =(k-2)^{2}-2\left(k^{2}+3 k+5\right) \\
& =-(k+5)^{2}+19 .
\end{aligned}
$$

Since the equation has two real roots, the value of $k$ must satisfy the following condition:
$$
\Delta=(k-2)^{2}-4\left(k^{2}+3 k+5\right) \geqslant 0,
$$

which simplifies to
$$
3 k^{2}+16 k+16 \leqslant 0 \text {, }
$$

Solving this, we get
$$
-4 \leqslant k \leqslant-\frac{4}{3} \text {. }
$$

Therefore, the problem of finding the maximum value of $x_{1}^{2}+x_{2}^{2}$, under the condition $-4 \leqslant k \leqslant-\frac{4}{3}$, is equivalent to finding the maximum value of the function
$$
y=-(k+5)^{2}+19
$$

under the same condition. Since the axis of symmetry $k=-5$ is outside the interval $\left[-4,-\frac{4}{3}\right]$, the function is monotonically decreasing on $\left[-4,-\frac{4}{3}\right]$, and it achieves its maximum value at $k=-4$, which is 18.
$\therefore$ The maximum value of $x_{1}^{2}+x_{2}^{2}$ is 18.
6. Given that $x_{1}, x_{2}$ are the real roots of the equation
$$
x^{2}-(k-2) x+\left(k^{2}+3 k+5\right)=0
$$
( $k$ is a real number)
the maximum value of $x_{1}^{2}+x_{2}^{2}$ is
(A) 19 ;
(B) 18 ;
(C) $5 \frac{5}{9}$;
(D) does not exist.