Any court which commits a child to an institution or custodial agency shall determine the pecuniary ability of either or both parents to contribute to the support of such child and shall order such parent or parents to pay such sum for such support as is consistent with such pecuniary ability. If such commitment is to an institution or custodial agency not supported in whole or in part by the state, such order shall direct such parent or parents to pay to such institution the amount specified in such order, provided such amount shall not exceed the actual cost of the support of such child. Such institution or custodial agency may enforce such order by civil suit or by instituting contempt proceedings in the court issuing such order. If such commitment is to an institution or custodial agency supported in whole or in part by the state, such order shall direct such parent or parents to pay to the state an amount not exceeding the cost to the state of the support of such child in such institution and the Attorney General shall enforce such order by civil suit or by contempt proceedings. If such commitment is to an institution or custodial agency supported in whole or in part by the state, such court shall certify such commitment to the Commissioner of Social Services or his designee. The provisions of this section shall not apply to any commitment to the Newington Children’s Hospital.