Example 11 Find the range of real number $a$ such that for any real number $x$ and any $\theta \in\left[0, \frac{\pi}{2}\right]$ we always have
$$
(x+3+2 \sin \theta \cos \theta)^{2}+(x+a \sin \theta+a \cos \theta)^{2} \geqslant \frac{1}{8} .
$$
Let $t=\sin \theta+\cos \theta$, then
$2 \sin \theta \cos \theta=t^{2}-1$.
Then the left side of the original expression $=\left(x+t^{2}+2\right)^{2}+(x+a t)^{2}$
$$
\begin{array}{l}
\geqslant \frac{1}{2}\left[\left(x+t^{2}+2\right)-(x+a t)\right]^{2} \\
=\frac{1}{2}\left(t^{2}-a t+2\right)^{2} \geqslant \frac{1}{8} \text { always holds. }
\end{array}
$$

Thus, $t^{2}-a t+2 \geqslant \frac{1}{2}$ or $t^{2}-a t+2 \leqslant-\frac{1}{2}$.
Since $t=\sin \theta+\cos \theta=\sqrt{2} \sin \left(\theta+\frac{\pi}{4}\right) \in[1, \sqrt{2}]\left(\theta \in\left[0, \frac{\pi}{2}\right]\right)$, then $a \leqslant t+\frac{3}{2 t}$ or $a \geqslant t+\frac{5}{2 t}$ always holds.
When $t \in[1, \sqrt{2}]$,
$$
t+\frac{3}{2 t} \geqslant \sqrt{6}, t+\frac{5}{2 t} \leqslant \frac{7}{2} \text {. }
$$

Therefore, when $a \leqslant \sqrt{6}$ or $a \geqslant \frac{7}{2}$, the original inequality always holds.