Getting code onto a microcontroller
How the code gets loaded will depend on the type of microcontroller being used. Some possible schemes used:


The MCU gets its program code from a ROM (read only memory) that is manufactured onto the part.
The MCU has FLASH memory built onto the chip that contains the program code. This FLASH may be programmed in a number of ways. (see below)
The MCU may load its program code from an external memory chip. This external memory could be a ROM, serial FLASH, FRAM chip or for some older types of products an EEPROM or parallel FLASH.


Embedded products that have the program code on re-programmable memory such as the on-chip FLASH or serial FLASH chip as mentioned above can have their program code loaded via:


The code is programmed into the bare component before it is soldered down to the board.
Sometimes the MCU or FLASH device is placed into a socket where it can be removed for programming at the chip level using an external programmer. 
There may be a special connector or header that is used to connect an external programming device that allows loading of the program code. 
Some high volume products do away with the connector mentioned above and allow access via spring loaded pins to test points on the board to permit a programmer to access the FLASH programming pins.