The OS is stored on the hard drive. However, if you change your motherboard then you will need a new OEM Windows license. Replacing the motherboard = new computer to Microsoft.
Edit- identical motherboard replacement is ok as Brett stated.
Hard drive.. Rwpritchett is right btw Microsoft sees a change of a motherboard as a major change so you will have to buy a new licence key for windows.
I think at some time or another mobo makers will start to put nand flash memory on the motherboard to store just the OS well see if it happens I have a feeling at some point someone will do it at some point.