Green’s Dictionary of Slang

keg v.1

also kag
[keg n.; the image is of leaving the beer in the keg]

(US) to abstain from drinking alcohol.

T. Anburey Travels I 193: ‘I’ll keg myself for six months, directly I get home.’ The word keg [...] is a cant word that the soldiers have among them, when they wish to refrain from liquors [DAE].
J. MacGregor British America I 221: From the cheapness of rum, the labouring people [...] acquire habits of excessive drinking, which they have only resolution to resist by swearing [...] that they will not taste rum, or spirits of any kind. This act is called Kegging, extending to one or more years, and often for life [DAE].
[US]T. Haliburton Clockmaker II 172: I kag’d for a month [...] he had taken an oath to abstain from drawing liquor from the keg – they calls it kaggin’.
[Scot]P.T. Barnum Autobiog. 36: Once in a while he would ‘keg,’ as he called it; that is, he would abjure strong drink for a certain length of time.