To see that there are at least four connected components, write $A$ blockwise:
$$A=\begin{pmatrix} B & C \\ D & E \end{pmatrix},\qquad B\in M_n, E\in M_k.$$
Then $A^TGA=G$ decomposes as three identities, among which
$$B^TB=I_n+C^TC,\qquad E^TE=I_k+D^TD.$$
The matrix $B^TB$ is thus larger (in the sense of symmetric matrices) than $I_n$, hence positive definite. There follows that $B$ is always non-singular. The same is true for the block $E$. Now form the map
$$f:O(n;k)\rightarrow\{\pm1\}^2,\qquad f(A)=({\rm sgn}(\det B),{\rm sgn}(\det E)).$$
From above, this is a continuous function (the determinants don't vanish). When $nk\ge 1$, it is obviously onto (consider diagonal elements of the group). Hence $O(n;k)$ has at least as many connected components as the target $\{\pm\}^2$, that is four.

To see that there are exactly four connected components, you have to prove that $O(n;k)$ is stable under the polar decomposition. Next prove that $O(n;k)\cap SPD_{n+k}$ is homeomorphic (through the exponential map) to a vector space, and check that $O(n;k)\cap O(n+k)\sim O(n)\times O(k)$. Since $O(n)$ and $O(k)$ have two connected components, you are done.

**Remark**. The map $f$ defined above is a group homomorphism !

**Reference**: see my book *Matrices. Springer-Verlag GTM 216.* In the second edition, it Chapter 10.