5. In the right triangle $\triangle AOB$, $\angle O=90^{\circ}$, and a Cartesian coordinate system is established with the lines $OA$ and $OB$ as the coordinate axes, as shown in Figure 3. A square $ABCD$ is constructed outward with $AB$ as one side, and the diagonals $AC$ and $BD$ intersect at point $P$. Given $A(0,3)$ and $OP=4\sqrt{2}$. When the graph of the inverse proportion function $y=\frac{k}{x}$ passes through point $D$, the value of $k$ is ( ).
(A) 6
(B) 12
(C) 24
(D) $12\sqrt{2}$
5. C.

As shown in Figure 7, draw $P E \perp$
$O B$ at point $E$, $P F \perp O A$
at point $F$, $P G \perp O A$ at point $G$.
It is easy to prove,
Rt $\triangle A F P$
$\cong \mathrm{Rt} \triangle B E P$
$$
\Rightarrow F P=E P
$$
$\Rightarrow$ Quadrilateral $P F O E$ is a square
$\Rightarrow O E=O F=\frac{\sqrt{2}}{2} O P=4$
$$
\Rightarrow B E=A F=4-3=1, O B=4+1=5 \text {. }
$$

Notice,
$$
\begin{array}{l}
\text { Rt } \triangle A G D \cong \mathrm{Rt} \triangle B O A \\
\Rightarrow D G=O A=3, A G=O B=5 \\
\Rightarrow x_{D}=3, y_{D}=8 \Rightarrow k=24 .
\end{array}
$$