I think your problem can be written as an optimization problem.
$\{x_i\}$ is the set of points for plane 1, $\{x_j\}$ for plane 2 respectively. Their orthonormal vectors are $n_1$ and $n_2$ with constraints: $|n_1|=1$, $|n_2|=1$ and $n_1n_2=0$.
$\{\lambda_i\}$ the set of lagrange multiplier.
The functional under constraints reads
$$
\sum_i (x_i n_1-c_1)^2 +\sum_j(x_jn_2-c_2)^2+\lambda_1 n_1n_2+\lambda_2(n_1n_1-1)+\lambda_3(n_2n_2-1)
$$
So you are looking for the minimum of the functional with parameter set $\{n_{1x},n_{1y},n_{1z},n_{2x},n_{2y},n_{2z},c_1,c_2,\lambda_1,\lambda_2\lambda_3\}$.
Of course, if you parametrize the conditions into the normal vectors of the planes you can skip the lagrange multiplier.
Edit
Update to answer your question.
This approach will guarantee orthogonality (within the numerical accuracy of representing $\lambda_i$). You can easily see this, if you don't use lagrange multipliers but choose spherical coordinates for your normal vectors.
Let's say $\phi_i, \theta_i$ are the spherical coordinates ($\phi_i\in[-\pi,\pi], \theta_i\in[0,\pi]$), $|n_i|=1$ is then already in the parametrization and the additional condition $n_1n_2=0$ will lead to a condition on $\theta_2$:
$\cot\theta_2=\frac{\sin\theta_1(\cos \phi_1 \cos\phi_2+\sin \phi_1 \sin\phi_2)}{\cos \theta_1}$ with $\theta_1 \neq \frac{\pi}{2}$, which you can use to express $n_2$ with $\{\phi_1,\theta_1,\phi_2\}$.
Now, if you plug this into the posted functional you will see that it obeys this parametrization as well and you are left with the set of free parameters $\{c_1,c_2,\phi_1,\phi_2,\theta_1\}$.
But as you can see, if you choose such a map for $\mathbb{R}^3$, you have to deal with all degenerancies of the map, which is unfovarable in this case.
Playing around with a test case I like to add some more information about numerical minimization with lagrange constraints.
Numerical minimzation routines have problems with saddle points. One way to circumvent such a problem is not to minimize the functional stated above, but to minimze the norm of its gradient $|\nabla f|$.
Here is my mathematica test case:
$f$ is the functional without constraints.
$g$ are the lagrange multiplier and constraints.
$ll$ is the functional as written above.
$lll$ is the norm of the gradient of the functional above.
In[256]:= ClearAll["Global`*"]
x1 = RandomReal[1, {17, 3}];
x2 = RandomReal[1, {17, 3}];
vars = {n1, n2, n3, c1, m1, m2, m3, c2, l1, l2, l3}
f[n1_, n2_, n3_, c1_, m1_, m2_, m3_, c2_] =
Total[(x1.{n1, n2, n3} - c1)^2] + Total[(x2.{m1, m2, m3} - c2)^2];
g[n1_, n2_, n3_, m1_, m2_, m3_, l1_, l2_, l3_] =
l1 ({n1, n2, n3}.{n1, n2, n3} - 1) +
l2 ({m1, m2, m3}.{m1, m2, m3} - 1) + l3 ({n1, n2, n3}.{m1, m2, m3});
ll[n1_, n2_, n3_, c1_, m1_, m2_, m3_, c2_, l1_, l2_, l3_] =
f[n1, n2, n3, c1, m1, m2, m3, c2] +
g[n1, n2, n3, m1, m2, m3, l1, l2, l3];
lll[n1_, n2_, n3_, c1_, m1_, m2_, m3_, c2_, l1_, l2_, l3_] :=
Table[D[ll @@ vars, vars[[i]]], {i, 1, Length[vars]}].Table[
D[ll @@ vars, vars[[i]]], {i, 1, Length[vars]}]
s = FindMinimum[
lll[n1, n2, n3, c1, m1, m2, m3, c2, l1, l2,
l3], {{n1, 1.0}, {n2, 0}, {n3, 1}, {m1, 0.0}, {m2, 1}, {m3,
1}, {c1, 1}, {c2, 2}, {l1, 1}, {l2, 2}, {l3, 3}}]
FullSimplify[lll[n1, n2, n3, c1, m1, m2, m3, c2, l1, l2, l3] /. s[[2]]]
FullSimplify[g[n1, n2, n3, m1, m2, m3, l1, l2, l3] /. s[[2]]]
FullSimplify[f[n1, n2, n3, c1, m1, m2, m3, c2] /. s[[2]]]
{n1, n2, n3}.{n1, n2, n3} - 1 /. s[[2]]
{m1, m2, m3}.{m1, m2, m3} - 1 /. s[[2]]
{n1, n2, n3}.{m1, m2, m3} /. s[[2]]
Out[259]= {n1, n2, n3, c1, m1, m2, m3, c2, l1, l2, l3}
Out[264]= {6.88327*10^-30, {n1 -> 0.441163, n2 -> -0.600498,
n3 -> 0.666916, m1 -> 0.243615, m2 -> 0.795371, m3 -> 0.55501,
c1 -> 0.244619, c2 -> 0.855017, l1 -> -1.43598, l2 -> -0.740652,
l3 -> -0.329995}}
Out[265]= 1.07099*10^-29
Out[266]= -1.83184*10^-17
Out[267]= 2.17663
Out[268]= 0.
Out[269]= 0.
Out[270]= 5.55112*10^-17
As you can see, the solution planes are orthonormal within numerical noise.