It's either set by the user, or it's already set on the device based on the market the product is selling into. Phones have GPS though, so I'm not sure how that factors into it.
It's usually programmed into an EEPROM inside the device. Nowadays for compliance reasons, the radio firmware may enforce it rather than the software driver.