$G$ is a abelian if and only if $\mathfrak g$ is abelian? Let $G$ be a connected Lie group and let $\mathfrak g$ its Lie algebra. We know that $$(*) \quad G \, \mbox{is a  abelian if and only if  } \mathfrak g  \, \mbox{is abelian}.$$
I search a counterexample of $(*) $ when $G$ is not connected.
Thank you in advance
 A: The Lie algebra of $O(2)$ is abelian, yet the Lie group $O(2)$ is non-abelian. We have
$$
\begin{pmatrix} -1 & 0 \\ 0 & 1 \end{pmatrix}\begin{pmatrix} 0 & 1 \\ -1 & 0 \end{pmatrix} \neq \begin{pmatrix} 0 & 1 \\ -1 & 0 \end{pmatrix}\begin{pmatrix} -1 & 0 \\ 0 & 1 \end{pmatrix}.
$$
A: A Lie group $G$, not necessarily connected, fits into a canonical short exact sequence
$$1 \to G_0 \to G \to \pi_0(G) \to 1$$
where $G_0$ is the connected component of the identity and $\pi_0(G)$ is the group of connected components. Now, $\mathfrak{g}$ is abelian iff $G_0$ is abelian. It can still happen that $G$ is nonabelian. 
The simplest way is if $\pi_0(G)$ is nonabelian, as mentioned in the comments. More interestingly, as in Dietrich Burde's answer, it can happen that $\pi_0(G)$ is abelian but that the extension above is nontrivial enough that $G$ still ends up nonabelian. In Dietrich Burde's example of $O(2)$ the extension 
$$1 \to SO(2) \to O(2) \to \mathbb{Z}_2 \to 1$$
is a nontrivial semidirect product; the corresponding action of $\mathbb{Z}_2$ on $SO(2)$ is by inversion. 
