Often enough you were given a choice if your ship was boarded by pirates. Otherwise, I imagine you'd have the opportunity to sign on in one of the ports that sometimes allowed pirates into harbor.