Custody could go to you if there were a modification hearing.  If he is only going to jail for a few days (like to sit out a ticket), he could designate a caregiver to provide for the child while he was in custody.  If he is going away for a longer period, he could still technically designate someone to provide for the child while he was in custody, but you would also have a basis for seeking a modification of the custody orders... that being that a parent, not a stranger, should be raising your child.  Your rights as a biological parent would prevail over a third-party, non-parent.