I am considering the line, $L: \vec{r}=\vec{a}+\mu\vec{b}$, and the point, $P$. I will define $Q$ as the point along $L$ such that the distance from $P$ to $Q$ is the shortest possible distance from $P$ to the line $L$. (I assume that we explicitly know what $\vec{a}, \vec{b}$ and $\overrightarrow{OP}$ are.)
This means that $\overrightarrow{PQ}$ must be perpendicular to the line $L$, so $$\overrightarrow{PQ} \cdot \vec{b} = 0$$ because $\vec{b}$ is a direction vector of L and the dot product of any 2 perpendicular vectors is always zero.
By vector addition, $\overrightarrow{PQ} = \overrightarrow{PO} + \overrightarrow{OQ} = \overrightarrow{OQ} - \overrightarrow{OP}$.
And because $Q$ lies on $L$, we know that $\overrightarrow{OQ} = \vec{a} + \mu_Q \vec{b}$ for some constant, $\mu_Q$.
$$\therefore \overrightarrow{PQ} = \vec{a} + \mu_Q \vec{b} - \overrightarrow{OP}$$ and recalling that $\overrightarrow{PQ} \cdot \vec{b} = 0$ and applying the distributivity of the dot product, $$\overrightarrow{PQ}\cdot\vec{b}=\left( \vec{a} + \mu_Q \vec{b} - \overrightarrow{OP} \right)\cdot\vec{b}=\vec{a}\cdot\vec{b}+ \mu_Q \vec{b}\cdot\vec{b} - \overrightarrow{OP}\cdot\vec{b}=\vec{a}\cdot\vec{b}+ \mu_Q b^2 - \overrightarrow{OP}\cdot\vec{b} = 0$$ where $b=\|\vec{b}\|$.
$$\therefore \mu_Q b^2 = \overrightarrow{OP}\cdot\vec{b} - \vec{a}\cdot\vec{b} = \left(\overrightarrow{OP} - \vec{a}\right)\cdot\vec{b}$$ $$\implies \mu_Q = \frac{1}{b^2}\left(\overrightarrow{OP} - \vec{a}\right)\cdot\vec{b}$$ Substituuting the abover result into our expression for $\overrightarrow{PQ} = \vec{a} + \mu_Q \vec{b} - \overrightarrow{OP}$ yields: $$\overrightarrow{PQ} = \vec{a} + \left[\frac{1}{b^2}\left(\overrightarrow{OP} - \vec{a}\right)\cdot\vec{b}\right]\vec{b} - \overrightarrow{OP}$$ We know that $\vec{b} = \|\vec{b}\| \hat{b} = b \hat{b}$, where $\hat{b}$ is the unit vector of $\vec{b}$. Therefore: $$\overrightarrow{PQ} = \vec{a} + \left[\frac{1}{b^2}\left(\overrightarrow{OP} - \vec{a}\right)\cdot (b\hat{b})\right] (b\hat{b}) - \overrightarrow{OP} = \vec{a} + \left[\frac{b^2}{b^2}\left(\overrightarrow{OP} - \vec{a}\right)\cdot \hat{b}\right] \hat{b} - \overrightarrow{OP}$$
$$\implies \overrightarrow{PQ}= \vec{a} + \left[\left(\overrightarrow{OP} - \vec{a}\right)\cdot \hat{b}\right] \hat{b} - \overrightarrow{OP}$$
Therefore, the shortest distance from $P$ to $L$ would be: $$\implies \|\overrightarrow{PQ}\|= \Bigg\lVert \vec{a} + \left[\left(\overrightarrow{OP} - \vec{a}\right)\cdot \hat{b}\right] \hat{b} - \overrightarrow{OP} \Bigg\rVert$$ Is this correct?
It's probably all correct, although if an exam question is to find the shortest distance, you don't need to memorise that formula for an exam: Your method of starting by setting $\overrightarrow{PQ}\cdot\vec{b} = 0 \implies \left( \vec{a} + \mu_Q \vec{b} - \overrightarrow{OP} \right)\cdot\vec{b} = 0\ $ is good, and from there you find $\mu_{Q}$ because you have one equation with one unknown $(\mu_{Q}).$ Then just sub that value of $\mu_{Q}$ back into the equation $\overrightarrow{PQ} = \vec{a} + \mu_Q \vec{b} - \overrightarrow{OP},$ and take the magnitude and you're done.