The prevalent custom is to recite the Beracha of "She’ha’kol" over chocolate, despite the fact that chocolate is produced from the coca bean, which, of course, grows on trees. Rav Shlomo Zalman Auerbach (Jerusalem, 1910-1995) discussed this issue at length, and felt that in truth, especially for Sepharadim, the proper Beracha over chocolate is "Ha’etz," the Beracha recited over fruits. He observes that chocolate products seem to resemble the case discussed by the Shulhan Aruch (203) of ginger which was crushed into a spice, and sugar was then added. The Shulhan Aruch ruled that one recites "Ha’etz" over this product, and chocolate, seemingly, is no different. Rav Shlomo Zalman proposes several possible distinctions, but finds them all unsatisfactory, and is left without a compelling reason to recite "She’ha’kol" instead of "Ha’etz" over chocolate.
Hacham Bension Abba Shaul (Israel, 1924-1998) suggested a distinction between ordinary fruit trees, which are planted and grown, and trees that grow in the wild. Since cocoa beans grow wild, Hacham Bension reasoned, they differ from other fruits, and require "She’ha’kol," instead of "Ha’etz" (notwithstanding the view of the Arizal that even fruits that grow wild require the Beracha of "Ha’etz"). Others claim that chocolate is different because the beans are pulverized into a powder, and so they lose their status as fruits. Another theory is that since chocolate is given a special, distinctive name once it is produced, it is no longer considered the fruit of a tree.
Regardless, as mentioned, the accepted practice is to recite "She’ha’kol" over chocolate.
However, the possibility that the proper Beracha is "Ha’etz" is practically relevant in the common case of a person who eats both fruit and chocolate for dessert. Hacham Ovadia Yosef, in his Yabia Omer (vol. 8), observes that if one recites a Beracha over the fruit before eating the chocolate, then according to the view that chocolate is treated as a fruit, the Beracha of "Ha’etz" covers the chocolate. As such, if the person then recites a Beracha over the chocolate, this would constitute a Beracha Le’batala (Beracha recited in vein). On the other hand, according to the prevalent custom, he cannot eat the chocolate without reciting a Beracha. Therefore, Hacham Ovadia writes, a person in this situation should have specific intention when reciting the Beracha over the fruit that the Beracha should not cover the chocolate, and he then recites "She’ha’kol" before eating the chocolate. If he did not have this specific intention when reciting the Beracha over the fruit, then he does not recite a Beracha over chocolate, given the uncertainty as to whether a Beracha is warranted.
This is a very common circumstance, and therefore it is important to be aware of the view that chocolate requires "Ha’etz," as this opinion is practically relevant even though it is not followed.
Summary: The prevalent practice is to recite "She’ha’kol" over chocolate, even though it grows on trees, and various theories have been advanced to explain the distinction between chocolate and fruits. In any event, some Poskim maintained that the proper Beracha is "Ha’etz." Therefore, if one is eating fruit and chocolate, and eats the fruit before the chocolate, he must specifically have in mind that the Beracha of "Ha’etz" over the fruit does not cover the chocolate. If he did not have this in mind, then he does not recite a Beracha over the chocolate.