When a defendant is committed to jail, on failure to pay any fines and costs, he or she shall, under the supervision of the county sheriff and subject to the terms of any ordinances adopted by the county commissioners, be permitted to perform labor to reduce the amount owing of the fine and costs.