There is a standard Accounts-to-Accounts relationship that serves as standard functionality for this purpose.
On the Accounts module there is a Member Organisations subpanel that can be used to link existing account records in. This would serve as relating the company locations to the head office record.
There is a field on the record called Member Of which serves as the field on each company location record where you would choose the head office Account.
You can create the relationship from either location. If you require further instructions, you can find them here.
