It shall be lawful for any contractor to withhold from any subcontractor under him sufficient sums to cover any penalties withheld from him by the awarding body on account of the subcontractor’s failure to comply with the terms of this chapter, and if payment has already been made to the subcontractor the contractor may recover from him the amount of the penalty or forfeiture in a suit at law.