An answer should come in two parts. First, the connected component of $H$ is $H_0 = \prod \mathrm{SO}(t_i)^d$ and one has a normal covering
$$H/H_0 \longrightarrow G/H_0 \longrightarrow G/H.$$
Because you want real coefficients, the projection embeds the ring you want as the $H/H_0$-invariants of the "easier" ring $H^*(G/H_0)$. I'll explain this after we compute this ring.
Assume $G$ is connected; if not, then $H^*(G/H_0)$ will factor as a direct product of $\pi_0 G$-many copies of $H^*(G_0/H_0)$ anyway. The ring $H^*(G/H_0)$ is the cohomology of the algebra
$$H^*(BH_0) \otimes H^*(G)$$
with a differential $d$ vanishing on the first factor and defined on generators of the exterior algebra $H^*(G) = \Lambda P$ as the composition
$$P \overset\sim\longrightarrow sP \overset\sim\longrightarrow \frac{\tilde H^*(BG)}{\tilde H^*(BG)\cdot \tilde H^*(BG)} \rightarrowtail H^*(BG) \longrightarrow H^*(BH_0).$$
This bears some explanation. The first arrow is a regrading shifting things up one degree: $(sP)^{n+1} := P^n$, and the second isomorphism is due to Borel, who says that elements of these degrees form a set of polynomial generators for $H^*(BG)$ (the composition of these two maps is the transgression in the Serre spectral sequence of the universal bundle $G \to EG \to BG$). The third arrow is a fixed but arbitrary choice of lifting of this module of generators to a subspace of the cohomology ring, and the last map is induced by the inclusion $H_0 \hookrightarrow G$.
Both your rings are examples of this setup. In practice, one describes $H^*(BG)$ as $H^*(BT)^{W_G}$ for $T$ the maximal torus of $G$ and $W_G$ its Weyl group, and the last arrow is determined in terms of the inclusion of the maximal torus of $H_0$ into that of $G$.
To compute invariants, the action of $H/H_0$ on $H^*(G/H_0)$ is induced from that on $H^*(BH_0)$ and is also best computed on the torus level. I won't spell it out in complete detail, but for a generalizable example, the nontrivial element of $\frac{\mathrm{S}(\mathrm{O}(2) \times \mathrm O(2))}{ \mathrm{SO}(2) \times \mathrm{SO}(2)}$ acts on $$H^*\big(\mathrm{SO}(2) \times \mathrm{SO}(2)\big) = \mathbb R[t_1,t_2]$$ (where $|t_j| = 2$) by sending $t_1 \mapsto -t_1$ and $t_2 \mapsto -t_2$, so the invariants are $\mathbb R[t_1^2,t_1 t_2, t_2^2]$.
What happens in your special orthogonal example depends on what $n$ is, as one needs to know if there is an Euler class to worry about. The special unitary case is more uniform.
For a simple example of how such a calculation works, let's consider in $\mathrm{SU}(3)$ the subgroup $S = H = \mathrm{S}\big(\mathrm{U}(1)_\Delta \times \mathrm U(1)\big) = \big\{(z,z,z^{-2})\big\} \cong \mathrm U(1)$. If one considers the maximal torus $T$ of $\mathrm{SU}(3)$ as $\big\{(z,w,zw^{-1})\big\}$, then the inclusion can seen as a sort of diagonal map, and induces $$\mathbb R\cdot\{t_1,t_2\} = H^1(T) \to H^1(S) = \mathbb R\cdot s$$ taking both $t_1,t_2 \mapsto s$. The map $H^2(BT) \to H^2(BS)$ admits the same description. The generators $z_3,z_7$ of $H^*\mathrm{SU}(3)$ are sent to $-(t_1t_2 + t_1^2 +t_2^2)$ and $-(t_1t_2^2 + t_1^2 t_2)$, which are the reductions of the elementary symmetric polynomials $c_2$ and $c_3$ in $t_1,t_2,t_3$ under the identification $t_1+t_2+t_3 = 0$ (the elementary symmetric polynomials generate the $S_n$-invariants of $H^*(BT^n)$, which is $H^*B\mathrm U(n)$, and one "takes trace equal zero" to get the special unitary case).
So these generators go under the differential of
$$\mathbb R[s] \otimes \Lambda[z_3,z_5]$$
to $-3s^2$ and $-2s^3$ respectively. One can compute the cohomology algebra then as
$$\mathbb R[s] / (s^2) \otimes \Lambda [z],$$
where $z_3 - 2sz_2/3$ represents $z$.
This algebra is originally due to Cartan and the theorem can also be expressed as a ring isomorphism
$$H^*(G/H_0) \cong \mathrm{Tor}^*_{H^*(BG)}\big(\mathbb R,H^*(BH_0)\big).$$
There is a generalization of this to coefficients in some other ring $k$, usually expressed in terms of the collapse of the Eilenberg—Moore spectral sequence of the fibration $G/H_0 \to BH_0 \to BG$ (see references in Peter May's answer here: Cohomology groups of homogeneous spaces), but this depends on enough primes being invertible or zero in $k$ to make $H^*BG$ and $H^*BH_0$ polynomial.
The standard secondary source for this is the third volume of the book by Greub, Halperin, and Vanstone. A rational version is also developed more economically in more recent books on rational homotopy theory by Felix, Oprea, and Tanré and by Felix, Halperin, and Thomas, but GHV has the best examples section.