On a chemical level, no: ecstasy, cocaine, and similar drugs have not been found to decrease the effectiveness of hormonal birth control such as Plan B. (Some prescription drugs and herbs do, though, so be sure your healthcare providers know what you’re taking.)
However, drug use can affect your sexual health choices in other ways. It’s well-documented that those under the influence are more likely to engage in unprotected sex, increasing the risk of STI transmission. Being drunk or high can also negatively affect a person’s communication, decreasing their ability to set boundaries, read a partner’s reactions, and give or withdraw their consent. They may not be able to look out for their friends or themselves.