  In this paper, we establish the two weight commutator of Calder\'on--Zygmund
operators in the sense of Coifman--Weiss on spaces of homogeneous type, by
studying the weighted Hardy and BMO space for $A_2$ weight and by proving the
sparse operator domination of commutators. The main tool here is the Haar basis
and the adjacent dyadic systems on spaces of homogeneous type, and the
construction of a suitable version of a sparse operator on spaces of
homogeneous type. As applications, we provide a two weight commutator theorem
(including the high order commutator) for the following Calder\'on--Zygmund
operators: Cauchy integral operator on $\mathbb R$, Cauchy--Szeg\"o projection
operator on Heisenberg groups, Szeg\"o projection operators on a family of
unbounded weakly pseudoconvex domains, Riesz transform associated with the
sub-Laplacian on stratified Lie groups, as well as the Bessel Riesz transforms
(one-dimension and high dimension).
