To be on the wagon is to refrain from drinking. It applies especially to someone who has been a serious drinker in the past. To be off the wagon is to be drinking, usually again after a period of sobriety.
There are a few theories behind the origin of on the wagon, but the idiom likely comes from the early 20th-century American expression on the water-wagon, which meant one was drinking water instead of alcohol. Whatever its origins, on the wagon apparently predates off the wagon.
On the wagon and off the wagon are sometimes used in reference to other addictions or compulsions—for example, they’re increasingly used in writing concerned with diet—but they originally referred to alcoholism.
On the wagon
For me, today is the 49th anniversary of my going on the wagon. Sobriety is a wonderful thing. [San Bernardino Sun]
Alcohol leads to cocaine. Then, after a two- or three-day binge, he goes back on the wagon. [No More Letting Go, Debra Jay]
When Bush went on the wagon he replaced alcohol with religion. [Marin Scope]
Off the wagon
Young alcohol dependents are also likely to fall off the wagon multiple times, according to the study, and for longer periods of time. [Los Angeles Times]
Like reformed alcoholics slipping off the wagon, frontier African economies are sliding back into bad old ways. [Globe and Mail]