For a weaker condition, this is true when $G$ is nilpotent. We can show the following
A finite group $G$ is nilpotent if and only if $|G_1G_2|$ divides $|G|$ for every subgroup $G_1$, $G_2$ of $G$.
If $G$ is nilpotent, then $G$ is a direct product of its Sylow subgroups. That is, $G = P_1 \times \ldots \times P_t$ where $P_i$ are the Sylow subgroups of $G$. Then $G_1$ and $G_2$ are nilpotent as well, so $G_1 = A_1 \times \ldots \times A_t$ and $G_2 = B_2 \times \ldots \times B_t$ where $A_i$ and $B_i$ are subgroups of $P_i$. Now the product $G_1G_2$ is not necessarily a subgroup, but it is of the form
$$G_1G_2 = A_1B_1 \times \ldots \times A_tB_t$$
so $|G_1G_2|$ divides $|G|$ because each $|A_iB_i|$ divides $|P_i|$.
For the other direction, note that for two Sylow $p$-subgroups $P$ and $Q$, the order $|PQ|$ divides $|G|$ if and only if $P = Q$. Hence for each prime divisor of $G$ there is exactly one Sylow subgroup, which implies that $G$ is nilpotent.