Suppose that $X$ is a $G$-space. If $O^\circ_x$ is the orbit of $x\in X$ under the action of $G^\circ$, then it turns out that $\dim\overline{O}_x=\dim\overline{O^\circ_x}$, $\dim\operatorname{Stab}_G(x)=\dim\operatorname{Stab}_{G^\circ}(x)$, and finally
$$
\dim(G)=\dim\overline{O}_x+\dim\operatorname{Stab}_G(x).
$$
So in particular, if $X$ is homogeneous $G$-space, then $X=O_x$, and the result follows.
Fix $x\in X$, and let $H=\operatorname{Stab}_G(x)$. You can decompose $G=\bigcup g_iG^\circ$ as finite disjoint union of the cosets of the identity component. Then $O_x=\bigcup g_iO^\circ_x$, so that $\overline{O}_x=\bigcup\overline{g_iO_x^\circ}$. But $\overline{g_iO^\circ_x}$ is a closed, irreducible subset for each $i$, since translation is an isomorphism of affine varieties, and thus $\dim\overline{g_iO^\circ_x}=\dim\overline{O^\circ_x}$ for all $i$. Hence we have $\dim\overline{O^\circ_x}=\dim\overline{O_x}$.
Since $G^\circ\unlhd G$, $G^\circ H$ is a subgroup of $G$, hence
$$
H/\operatorname{Stab}_{G^\circ}(x)=H/(G^\circ\cap H)\simeq G^\circ H/G^\circ,
$$
the isomorphism being one of abstract groups. But it's known $[G:G^\circ]$ is finite, so that $[H:\operatorname{Stab}_{G^\circ}(x)]$ is finite, hence $\dim H=\dim\operatorname{Stab}_{G^\circ}(x)$.
This shows it's essentially fine to just look at how $G^\circ$ acts, so we can assume $G$ is connected.
The orbit map $\varphi_x\colon G\to\overline{O}_x$ is a dominant map of irreducible affine varieties, so standard facts in algebraic geometry give a nonempty open $U\subseteq O_x$ such that
$$
\dim\varphi_x^{-1}(y)=\dim G-\dim\overline{O}_x,\quad\forall y\in U.
$$
It's well known that $G$-orbits are open in their closure, and so $O_x$ meets $U$ nontrivially. So we can pick $y\in O_x\cap U$, and so $y=gx$ for some $g\in G$. Thus
$$
\varphi_x^{-1}(y)=\{h\in G:gx=y=hx\}=\{h\in G:g^{-1}hx=x\}=\{h\in G:g^{-1}h\in H\}=gH.
$$
Since $gH\simeq H$ as varieties, $\dim\varphi_x^{-1}(y)=\dim H$. So we get
$$
\dim H=\dim G-\dim\overline{O}_x.
$$
The equation for when $X$ is a homogeneous $G$-variety now follows.