If a warehouse has been transferred to the purchase header, or selected manually, the location will also be transferred to the individual purchase lines. However, if the item on the purchase line has a mandatory warehouse, that location will be transferred to the purchase line instead.
If no warehouse is specified on the purchase header, the default warehouse (not necessarily the mandatory warehouse) for the item is transferred to the field on the purchase order line.
At any point, you can manually change the value of the warehouse field on the purchase header.