The distance between a point and a curve and is, of course, defined to be the minimal one.
Note that there are trivial solutions when $x=\frac{\pi}{4}+k\pi$ where $k$ is any integer because $\cos\left(\frac{\pi}{4}+k\pi-x\right)=\sin\left(\frac{\pi}{4}+k\pi+x\right)$, so the curves are mirrored around this line.
For a point $P=(P_x,P_y)$, and a differentiable function $f:\mathbb{R}\to\mathbb{R}$, I can define the function $d(x)$ to be the squared distance from $P$ to $(x,f(x))$, that is $d(x)=(x-P_x)^2+(f(x)-P_y)^2\implies d'(x)=2x-2P_x+2f(x)f'(x)-2P_yf'(x)$, so our minimum occurs when $x+f(x)f'(x)=P_x+P_yf'(x)$. If we let $f(x)=\sin(x)$, that is the same as $$x+\sin(x)\cos(x)=P_x+P_y\cos(x)$$ So if there is a closed form for that it may be possible to find the equation of the curve we're looking for. Letting $f(x)=\cos(x)$ generates something essentially equivalent: $$x-\sin(x)\cos(x)=P_x-P_y \sin(x)$$ So if $x_1$ is a solution of the first and $x_2$ of the second and $$(x_1-P_x)^2+(\sin(x_1)-P_y)^2=(x_2-P_x)^2+(\cos(x_2)-P_y)^2$$ then $P$ has the condition we're looking for, minus some extraneous solutions, where the zero of the derivative isn't a global minimum.