Theoretically, Which d orbital participates in sp3d and sp3d2?
The answer to this lies in the symmetry of the orbitals involved.

Naturally, an octahedral complex will have the point group $O_\mathrm{h}$ — the octahedral point group. In molecular orbital theory, we will first need to work out how the ligand group orbitals transform; then we can find out which metal orbitals transform identically, i.e. belong to the same irreducible representation; only these will form bonds with each other. To arrive at the group orbitals’ irreducible representations, we need to see how they transform under the given symmetry operations of the group; thankfully, a copy of the character table can be found on meta (Attention: MathJax heavy link! Give the page about 30 seconds time to load!) Since your diagram does not include &#x3c0; interactions, I will ignore them, too.

\begin{array}{lcccccccccc}\hline
\text{Irrep} &amp; E &amp; 8 C_3 &amp; 6 C_2 &amp; 6 C_4 &amp; 3 C_4^2 &amp; i &amp; 6 S_4 &amp; 8 S_6 &amp; 3 \sigma_\mathrm{h} &amp; 6 \sigma_\mathrm{d} \\ \hline
6 \sigma_{\ce{L\bond{-&gt;}M}} &amp; 6 &amp; 0 &amp; 0 &amp; 2 &amp; 2 &amp; 0 &amp; 0 &amp; 0 &amp; 4 &amp; 2 \\ \hline\end{array}

We now need to use the reduction formula to determine how many times each irreducible representation is part of this reducible representation.

$$n = \frac 1h \sum_{\chi} N \chi_\mathrm{r} \chi_\mathrm{i}\tag{1}$$

Wherein $n$ is the number of times an irreducible representation is included, $N$ is the coefficient of a symmetry operation group, $h$ is the sum of all coefficients ($48$ in $O_\mathrm{h}$) and $\chi$ is the character of the irreducible or reducible representation, respectively. Thankfully, a large number of reducible group characters end up as $0$, easing our calculations. This should be the result:

$$\begin{align}n(\mathrm{a_{1g}}) &amp;= \frac 1{48} (6 + 2 \times 6 \times 1 + 2 \times 3 \times 1 + 4 \times 3 \times 1 + 2 \times 6 \times 1) &amp;&amp;= 1\\
n(\mathrm{a_{2g}}) &amp;= \frac 1{48} (6 + 2 \times 6 \times (-1) + 2 \times 3 \times 1 + 4 \times 3 \times 1 + 2 \times 6 \times (-1)) &amp;&amp;= 0\\
n(\mathrm{e_g}) &amp;= \frac 1{48} (12 + 2 \times 6 \times 0 + 2 \times 3 \times 2 + 4 \times 3 \times 2 + 2 \times 6 \times 0) &amp;&amp;= 1\\
n(\mathrm{t_{1g}}) &amp;= \frac 1{48} (18 + 2 \times 6 \times 1 + 2 \times 3 \times (-1) + 4 \times 3 \times (-1) + 2 \times 6 \times (-1)) &amp;&amp;= 0\\
n(\mathrm{t_{2g}}) &amp;= \frac 1{48} (18 + 2 \times 6 \times (-1) + 2 \times 3 \times (-1) + 4 \times 3 \times (-1) + 2 \times 6 \times 1) &amp;&amp;= 0\\
n(\mathrm{a_{1u}}) &amp;= \frac 1{48} (6 + 2 \times 6 \times 1 + 2 \times 3 \times 1 + 4 \times 3 \times (-1) + 2 \times 6 \times (-1)) &amp;&amp;= 0\\
n(\mathrm{a_{2u}}) &amp;= \frac 1{48} (6 + 2 \times 6 \times (-1) + 2 \times 3 \times 1 + 4 \times 3 \times (-1) + 2 \times 6 \times 1) &amp;&amp;= 0\\
n(\mathrm{e_u}) &amp;= \frac 1{48} (12 + 2 \times 6 \times 0 + 2 \times 3 \times 2 + 4 \times 3 \times (-2) + 2 \times 6 \times 0) &amp;&amp;= 0\\
n(\mathrm{t_{1u}}) &amp;= \frac 1{48} (18 + 2 \times 6 \times 1 + 2 \times 3 \times (-1) + 4 \times 3 \times 1 + 2 \times 6 \times 1) &amp;&amp;= 1\\
n(\mathrm{t_{2u}}) &amp;= \frac 1{48} (18 + 2 \times 6 \times (-1) + 2 \times 3 \times (-1) + 4 \times 3 \times 1 + 2 \times 6 \times (-1)) &amp;&amp;= 0\end{align}$$

We see, that the six &#x3c3;-symmetric ligand orbitals transform as $\mathrm{a_{1g} + e_g + t_{1u}}$ — this is also shown in your picture. Now that we have this settled, we need to ask ourselves which metal orbitals these irreducibles correspond to. $\mathrm{a_{1g}}$, the totally symmetric irreducible is easy; it must be the $\mathrm{s}$ orbital. Furthermore, the character table tells us that $(x,y,z)$ transforms as $\mathrm{t_{1u}}$ which means that the $\mathrm{p}$ orbitals must transform as that. (You can verify this by performing the same exercise on the three central $\mathrm{p}$ orbitals.)

This leaves the $\mathrm{d}$ orbitals which — for symmetry reasons as there is no pentadegenerate irreducible — have to split up into at least a group of three and two ($\mathrm{t}_x$ and $\mathrm{e}_x$). Again, glancing at the character table tells us that $\mathrm{d}_{xy}, \mathrm{d}_{xz}$ and $\mathrm{d}_{yz}$ transform as $\mathrm{t_{2g}}$ and $\mathrm{d}_{x^2 - y^2}$ and $\mathrm{d}_{z^2}$ as $\mathrm{e_g}$. The first can easily be verified by the same exercise as for the $\mathrm{p}$ orbitals; the second not so easily due to the ‘unnatural’ shape of the $\mathrm{d}_{z^2}$ orbital. However, do trust the calculations that they are equivalent.

Therefore, it is only $\mathrm{d}_{z^2}$ and $\mathrm{d}_{x^2-y^2}$ that can interact with the ligand group orbitals and which therefore form the &#x3c3; bonds as your scheme shows. And this also makes sense from a purely qualitative point of view: The $\mathrm{d}_{z^2}$ orbital is pointing towards the $z$-axis ligands (and the ring is somewhat interacting with the $x,y$-axis ligands) while each of the four lobes of $\mathrm{d}_{x^2-y^2}$ is pointing towards a ligand on the $x$ or $y$ axis. The $\mathrm{t_{2g}}$ orbitals are pointing in between the coordinate axis directions and therefore between the ligands and are thus nonbonding with respect to &#x3c3; bonds.