Smell is a very direct sense. In order for you to smell something, molecules from that thing have to make it to your nose. Everything you smell, therefore, is giving off molecules -- whether it is bread in the bakery, onions, perfume, a piece of fruit or whatever. Those molecules are generally light, volatile (easy to evaporate) chemicals that float through the air into your nose. A piece of steel has no smell because nothing evaporates from it -- steel is a non-volatile solid.
At the top of your nasal passages behind your nose, there is a patch of special neurons about the size of a postage stamp. These neurons are unique in that they are out in the open where they can come into contact with the air. They have hair-like projections called cilia that increase their surface area. An odor molecule binds to these cilia to trigger the neuron and cause you to perceive a smell.
According to the book Molecular Biology of the Cell:
Humans can distinguish more than 10,000 different smells (odorants), which are detected by specialized olfactory receptor neurons lining the nose.... It is thought that there are hundreds of different olfactory receptors, each encoded by a different gene and each recognizing different odorants.
Each of the hundreds of receptors are encoded by a specific gene. If your DNA is missing a gene or if the gene is damaged, it can cause you to be unable to detect a certain smell. For example, some people have no sense for the smell of camphor.
When you smell many fruits or flowers, what you are smelling is esters evaporating from the fruit or flower. Esters are organic molecules. For example, the ester that gives a banana its smell is called isoamyl acetate, and the formula for it is CH3COOC5H11. The primary smell of an orange comes from octyl acetate, or CH3COOC8H17. Esters can now be made artificially, and that is where artificial flavors come from.