When you smell an apple pie, the first event that occurs is that the fumes enter your nasal cavity through inhaling. Your nasal cavity is lined with olfactory epithelium which are the cells involved in the process of the smelling.
What happens then is that the smell receptors found within the olfactory epithelium bind with the odors of the molecules and then send a message stimulating the brain. This message is sent through the olfactory nerve.
Now, the brain needs to distinguish the odor it received. The responsible part to do this is the olfactory bulb that is located in the fore brain.