If you work with coefficients in a field $\mathbb{F}$, assume that $H^*(BH;\mathbb{F})$ is a free $H^*(BG;\mathbb{F})$-module, and add the assumption that the Serre spectral sequence has a product structure (i.e. the map $$H^p(BG;\mathbb{F}) \otimes H^0(BG ; H^q(G/H;\mathbb{F})) \overset{\smile}\longrightarrow H^p(BG ; H^q(G/H; \mathbb{F})) = E_2^{p,q}$$ is an isomorphism) then the Serre spectral sequence collapses. This can be proved by considering the lowest row a potential differential could start on. (Unfortunately I don't know a reference.) This shows that $$H^*(BH;\mathbb{F}) \cong H^*(BG;\mathbb{F}) \otimes H^0(BG ; H^*(G/H;\mathbb{F}))$$ as $H^*(BG;\mathbb{F})$-modules. To get the conclusion you want you must further suppose that $\pi_0(G)$ acts trivially on $H^*(G/H;\mathbb{F})$, but in this case the product structure is automatic.
EDIT: Here is a proof (I will omit coefficients). Suppose that the Serre spectral sequence does not collapse, that the non-zero differential starting on the lowest row starts on the $q$th row, and the longest differential coming out of this row is a $d_r$.
Let $\{\bar{b}_i\}$ be obtained by choosing a homogeneous $H^*(BG)$-module basis for the free module $H^*(BH)$, and discarding those basis elements of degree $\geq q$. Then everything below the $q$th row is a permanent cycle, so the map $$\mathbb{F} \otimes_{H^*(BG)} H^*(BH) \to H^0(BG ; H^*(G/H))$$ is surjective in degrees $* < q$. Thus the restrictions $b_i$ of the $\bar{b}_i$ to $H^*(G/H)$ generate $H^0(BG ; H^*(G/H))$ as a $\mathbb{F}$-module in degrees $*<q$.
The non-trivial $d_r$ differential out of the $q$th row means that the differential out of $E^{0,q}_r$ must be non-zero, by the product structure, so must hit a class $0 \neq \sum x_i \otimes b_i$ with $\vert b_i \vert = q+1-r$. In the cohomology of $BH$ this means that the class $\sum x_i \cdot\bar{b}_i \in H^{q+1}(BH)$ has Serre filtration $>r$, but in degee $q+1$ the submodule $$H^*(BG)\{\bar{b}_i \, \vert \, \vert \bar{b}_i \vert < q+1-r\} \leq H^*(BH)$$ accounts for all such classes. This gives a nontrivial $H^*(BG)$-linear dependence between the $\bar{b}_i$, which contradicts that these formed part of a $H^*(BG)$-module basis of $H^*(BH)$.