401. Fragrant Fruit, Trees
58:2 The bracha one recites over a pleasant fragrance depends on its source. If the fragrance comes from a produce that is fit to eat, whether it’s the fruit of a tree or of the ground, even if the fruit is unfit to eat on its own like a lemon, nevertheless since its primary purpose is to be eaten, the bracha is “haNosein reiach tov b’peiros,” that G-d places a pleasing smell in the fruit. (Mishnah Brurah 216:9 favors the alternate text, “asher nasan reiach tov b’peiros,” in the past tense.) One only says the bracha if he intended to smell the fruit. If he meant to eat it and smelled it incidentally, one does not recite a bracha. One says this bracha when enjoying the scent of roasted coffee beans.
58:3 If the fragrance comes from a tree or from something of a tree, he recites “Borei atzei besamim,” that G-d created fragrant trees. This bracha is recited over such things as myrtle, roses and frankincense. This bracha is recited over things not primarily eaten. There is a difference of opinion as to whether or not it should be recited over pepper and ginger, so it is best not to smell these things and avoid the doubtful situation.