Today, the expression "the devil to pay" is used primarily to describe having an unpleasant result from some action that has been taken. An example is when someone has done something they should not have and, as a result, "there will be the devil to pay." Originally, this expression described one of the more unpleasant tasks aboard a wooden ship.
The "devil" was the wooden ship's longest seam in the hull. Caulking of seams between boards of the hull was done with "pay" or pitch (a kind of tar). The task of "paying the devil" (caulking the longest seam of the hull) was despised by every seaman.