5. In Rt $\triangle A B C$, it is known that $A C=6$, point $E$ is on side $A C$, satisfying $C E=2 A E, D$ is the midpoint of the hypotenuse $A B$, $F$ is a moving point on segment $B C$, satisfying $\angle E D F=$ $90^{\circ}$. Then the maximum value of $B F-F C$ is ( ).
(A) $2 \sqrt{2}$
(B) $2 \sqrt{3}$
(C) $3 \sqrt{2}$
(D) $3 \sqrt{3}$
5. B.

From the given conditions, $A E=2, C E=4$.
As shown in Figure 4, extend $E D$ to point $E^{\prime}$ such that $D E^{\prime}=E D$, and connect $B E^{\prime}$ and $F E^{\prime}$.
It is easy to see that $\triangle A E D \cong \triangle B E^{\prime} D$, and $A E \parallel E^{\prime} B$.
Thus, $F E=F E^{\prime}$, and $\angle E^{\prime} B F=90^{\circ}$.
Therefore, $E F^{2}=A E^{2}+B F^{2}$.
Let $B F=x, C F=y (x \geqslant 0, y \geqslant 0)$. Then $2^{2}+x^{2}=4^{2}+y^{2} \Rightarrow x^{2}-y^{2}=12$
$\Rightarrow x>y \geqslant 0$.
Notice that,
$$
\begin{array}{l}
(x-y)^{2}-\left(x^{2}-y^{2}\right)=2 y^{2}-2 x y \\
=2 y(y-x) \leqslant 0 \\
\Rightarrow(x-y)^{2} \leqslant x^{2}-y^{2}=12 \\
\Rightarrow x-y \leqslant 2 \sqrt{3} .
\end{array}
$$

When $y=0, x=2 \sqrt{3}$, the equality holds, at which point, point $F$ coincides with $C$.
Thus, the maximum value of $B F-F C$ is $2 \sqrt{3}$.