Normally before the training starts, but remember it s a bond. They will give your money back in max 3 years, depending on the time reported in your contract.
the payment can be advanced, or deducted from your pay check of half/ half. Usually you can find an agreement for that