If I have to write $2$ times square root of $x$, I would write it as $2\sqrt{x}$.
However, if I have $x$ times the square root of $2$, would I write it as $x\sqrt{2}$ or $\sqrt{2}x$? Is there any rule or convention that exists(like writing $3xy$ instead of $xy3$)?
There's not a well-established convention. Sometimes, if I write $\sqrt2x$, I'll put a downward stroke at the end of the square root sign to show more clearly where it ends. Another solution is to use a dot:
$$\sqrt2\cdot x$$
or to use exponential notation:
$$2^{1/2}x$$
If you just put the $x$ in front ($x\sqrt2$), nobody would say you're wrong, or if they do, they haven't really got a leg to stand on.
I'd be inclined to put the variable after the coefficient in many cases, though, particularly if I'm writing out a polynomial:
$$3x^2+\sqrt2x+9$$
just to keep it in the usual format.