When no order respecting the costs is made by the judge, they shall be allowed and paid in the same manner as costs in criminal prosecutions. In all cases where a person is required to give security to keep the peace, or for good behavior, the judge may further order the costs of prosecution, or any part of them, to be paid by the person, who shall stand committed until the costs are paid or the person is otherwise legally discharged.