The Phrase Finder says the current usage is to describe “impending trouble or other bad consequences from one’s actions. I settled on this expression after posting a review of a book about the Confederate camp for Union prisoners of war at Andersonville. The commandant, Captain Henry Wirz, was hanged (which certainly would be “other bad consequences”) after the war and a rigged trial. The phrase alludes to Faustian pacts in which people forfeit their soul to realize some wish or wanted goal. Thomas Brown wrote in Letters From the Dead to the Living in 1707, “…we knew we should have the Devil to pay…we have pawn’d our Souls…” Sailors named the seam that “…margins the waterways on a ship’s hull…” the Devil, and they called plugging the seam with caulk or tar “paying.” Sailors probably adopted the established phrase to describe the unpleasant task of seam caulking.