Self Sacrifice – יהרג ואל יעבור
I understand that one must- under specific circumstances- give his/her own life rather then transgress.Is this only in a case where one has an ultimatum do or die (get killed)? what if one is faced with the option do or kill yourself?
One must give up their life rather than transgress the sins of idol worship, adultery [and various other forbidden relations] and murder.
Taking one’s own life is also considered murder [see Igros Moshe C:M 104, Marcheshes Vol. 3, siman 26-30] and so there would be no permit to do so to avoid one of the other above sins. The Yam shel Shlomo [Bava Kama Perek 8 Siman 59] writes that an exception to this would be one who is faced with taking his own life or causing many other Jews to be killed, in which case he is permitted to take his own life.
The Yam shel Shlomo there brings an opinion that one who feels he will be unable to withstand the torture and will violate one of the above sins, may in fact take his own life. He brings various proofs that the halacha does not follow this opinion, rather as stated above.