In fact, the result holds even if you do not assume that we are dealing with finite index, provided you take the equality to be an equality of cardinalities. Just follow the idea Pete Clark suggests, but without assuming that the number of cosets is finite in either case. And remember that the number of distinct cosets of a subgroup $B$ in a group $A$ is equal, by definition, to the index of $B$ in $A$, $[A:B]$.
As to whether the $x_i$ are "coset representatives for $H$", remember that for a collection of elements to be "a set of coset representatives" we require that if $x_iH = x_jH$, then $i=j$, and that for every $g\in G$ there exists $i$ such that $gH = x_iH$ (thinking left cosets; right cosets work the same way). So $x_1,\ldots,x_n$ will not generally be "a coset representative" nor a set of coset representatives, but that is immaterial. Simply show that if $\{x_i\}_{i\in I}$ is a set of coset representatives for $K$ in $G$ (meaning, (i) for every $g\in G$ there exists $i\in I$ such that $gK = x_iK$; and (ii) for all $i,i'\in I$, if $x_iK = x_{i'}K$ then $i=i'$), and $\{y_j\}_{j\in J}$ is a set of coset representatives for $H$ in $K$ (meaning, (1) for every $k\in K$ there exists $j\in J$ such that $kH = y_jH$; and (2) for all $j,j'\in J$, if $y_jH = y_{j'}H$, then $j=j'$); then it follows that $\{x_iy_j\}_{(i,j)\in I\times J}$ is a set of coset representatives for $H$ in $G$ (meaning, you need to prove that (I) for all $g\in G$ there exists $(i,j)\in I\times J$ such that $gH = (x_iy_j)H$; and (II) for all $(i,j),(i',j')\in I\times J$, if $(x_iy_j)H = (x_{i'}y_{j'})H$, then $(i,j)=(i',j')$).
A fact that will no doubt be useful is to remember that for any group $A$ and any subgroup $B$ of $A$, $cB = dB$ if and only if $cB\cap dB\neq\emptyset$.
Let $G$ be the disjoint union of the cosets $Ha_1,...,Ha_n$, and furthermore, let $H$ be the disjoint union of the cosets $Kb_1,...,Kb_m$. For brevity, let $K_{i,j} := Kb_ia_j$ and
$\Phi = \{K_{i,j}: 1 \leqslant i \leqslant m,\,\, 1 \leqslant j \leqslant n\}$
First show that the collection $\Phi$ covers $G$. Supposing $x \in G$, there is some $j$ such that $x \in Ha_j$. In particular, $x = ha_j$ for some $h \in H$. Moreover, because $h \in H$ we also know there is some $i$ such that $h \in Kb_i$, which is to say $h = kb_i$ for some $k \in K$. But then $x = ha_j = kb_ia_j \in K(b_ia_j) = K_{i,j}$. This proves that $\Phi$ covers $G$.
Next, we will show $| \Phi | = mn$. To that end suppose $K_{p,q}=K_{r,s}$. We will show that $p=r$ and $q=s$. Now, because $Kb_p,Kb_r \subset H$, we know that $K_{p,q} \subset Ha_q$ and $K_{r,s} \subset Ha_s$. But by construction $Ha_q,Ha_s$ are disjoint when $q \neq s$. So it must be that $q = s$ and $a_q = a_s := a$. Consequently, we have
$Kb_p = (Kb_p)(a_qa^{-1}) = (K_{p,q})a^{-1} = (K_{r,s})a^{-1} = (Kb_r)(a_sa^{-1}) = Kb_r$.
So again by construction, it must be that $p = r$. This concludes the proof that $| \Phi | = mn$
Finish up with
$[G:K] = |\Phi| = mn = [H:K][G:H] = [G:H][H:K]$.
Also, you have not mentioned anything regarding normality of $H,K$. If you knew $H,K$ were normal subgroups of $G$, then as a @FofX noted, the third isomorphism theorem is applicable:
$(G/K) / (H/K) \cong G/H$.
Thus
$[G:K] $
$=|G/K| $
$= [G/K:H/K] \cdot |H/K| $
$= |(G/K)/(H/K)| \cdot |H/K| $
$= | G/H| \cdot |H/K| $
$= [G:H] \cdot [H:K]$
Where the fourth inequality follows from $|(G/K)/(H/K)| = |G/H|$ (which in turn is a direct result of the third isomorphism theorem.)
Best Answer
Even if $G$ is infinite, $|G/H|=2$. If $K$ is an intermediate subgroup, we have $2=|G/H|=|G/K||K/H|$. Since $2$ is prime, $|G/K|$ is either $1$ or $2$. If it is $1$, then $G=K$. If it's $2$, then $|K/H|=1$, so $K=H$.