The gemara says that in a situation of sakanas nefashos one is allowed to derive benefit from all items that are forbidden to benfit from i.e. orlah and kilei ha'kerem, but not from asheira wood. Although the gemara thinks originally that for pikuach nefesh one should be able to use asheira wood, the maskana rejects that. It seems that originally the gemara assumed that the issur to save one's life by doing avoda zara is only when they would be worshiping avoda zara, but here where they are merely benefiting from the avoda zara without worshiping it, the gemara thought that one would not have to give up their life to avoid that. The conclusion is that even to avoid benefiting from the asheira one would have to sacrifice their life.
The questions remains: Why? Why does one need to give up their life to avoid benefiting from avoda zara and not just for worshiping avoda zara?
Tosafos says that we are speaking about a case where the refuah element is not associated with the type of tree or anything physical, rather it comes from it being an avoda zarah tree. Since another tree of the same type that is not an avoda zara tree would not work, there is a concern that one will be drawn into the worship of avoda zarah since his life was saved using its powers. It would seem from Tosafos that this is a Rabbinic extension demanding יהרג ואל יעבור because using the avoda zara would inevitably lead to worshiping the avoda zarah. According to Tosafos, if one were using the physical components of the tree which just happens to be avoda zara, there is no concern.
The Ran has a different approach. He understands that included in the issur of avoda zara is the worshiping of avoda zara וכל אביזרייהו. Just as by גילוי עריות one must give up their life to avoid even the אביזרייהו of giluy arayos, avoda zara would be the same. By using avoda zara for refuah, one would be in violation of לא ידבק בידך מאומה which would be an איזרייהו דעבודה זרה, therefore one must give up their life to avoid it. The Ran holds that any la'av that is specific to avoda zara (or one of the big 3 aveiros), even one that you aren't חייב מיתה for it, you must give up your life.
Rashi seems to have a third approach. Rashi writes that using avoda zara to heal oneself is נראה כמודה בה, looks like you are agreeing and recognizing it, therefore one must avoid that even at the expense of their life. Rashi is difficult to understand. Is this concept of נראה כמודה בה an actual issur of avoda zarah? It sounds like some form of מראית עין where people will think that you are are recognizing the avoda zara even though you aren't. Why would one have to give up their life for that?
It seems to me that this can be explained based on the sugya in Sanhedrin 61b where Abaye and Rava argue whether avoda zara מאהבה ויראה qualifies as avoda zara. Abaye focuses on the persons actions and therefore holds that you are chayev, whereas Rava focuses on the mindset and says that since you don't accept it as a GOD and are only doing it out of fear or intimidation, you are patur. Even Abaye admits that in a situation where one is not at all accepting the avoda zara as a G-d such as standing in a church bowing down to an idle but thinking he's in a shul bowing to Hashem, it doesn't even qualify as a shogeg of avoda zara - אי קסבר בית הכנסת הוא והשתחוה לו, הרי לבו לשמים. Rashi points out that even if one were standing in a beis avoda zara, well aware of where he is and bows down with intent to Hashem, there is no punishment for worshiping avoda zara. Clearly we see that avoda zara is not violated by action alone. It is only violated when one intends to accept it as a god.
Being that avoda zara is only violated when one intends to worship, why do we ever require יהרג ואל יעבור by avoda zara? Why don't we just tell the person to have in mind to serve Hashem? Clearly, the obligation to sacrifice one's life is not just to avoid the technical violation of avoda zara. Doing an action that seems like avoda zara, even בצנעה with no one watching is a violation of ואהבת את ה' אלקיך for which one needs to sacrifice their life as we learn from בכל נפשך. Here too, Rashi is saying that since using asheira gives the impression of being מודה בה, even if no one is watching, one must give up their life. The din of יהרג ואל יעבור for avoda zara is not to avoid an issur avoda zarah, it is to avoid a violation of ואהבת את ה' אלקיך. Any connection to avoda zara that chazal deem a violation of אהבת השם one must give their life to avoid.