Most states have a low barring the distribution of counterfeit drugs, which this would appear to violate. For example, the Colorado Imitation and Counterfeit Controlled Substances Act, codified at Sections 18-18-419 to 18-18-424, Colorado Revised Statutes, makes it a minor drug felony (class 4) to distribute an imitation controlled substance which is "a substance that is not the controlled substance that it is purported to be but which, by appearance, including color, shape, size, and markings, by representations made, and by consideration of all relevant factors as set forth in section 18-18-421, would lead a reasonable person to believe that the substance is the controlled substance that it is purported to be." It already contains a placebo exception for medical professionals stating that it "shall not apply to practitioners licensed, registered, or otherwise authorized under the laws of this state to possess, administer, dispense, or distribute a controlled substance, if the distribution, possession, dispensing, or administering of the imitation controlled substance is done in the lawful course of his professional practice."
But there is an argument that the intended purposes of the use of the counterfeit rather than the real thing was to prevent a suicide, and that doing so had that effect, which might excuse the crime. The fact that B initiated the conversation by asking A and might have successfully obtained the drug if he asked someone else makes this defense particularly plausible. People who fail to commit suicide do not statistically just try again by another method, suicide is an impulsive action that if prevented is not nearly as likely to recur if someone fails to do so by one particular method.
Colorado expressly allows the use of physical force to prevent a suicide. "A person acting under a reasonable belief that another person is about to commit suicide or to inflict serious bodily injury upon himself may use reasonable and appropriate physical force upon that person to the extent that it is reasonably necessary to thwart the result." Section 18-1-703(1)(d), Colorado Revised Statutes. This isn't actually a use for physical force, but it informs the application of the "choice of evils" defense, codified at Section 18-1-702, Colorado Revised Statutes in Colorado, which provides (with nuances not reproduced here) that:
conduct which would otherwise constitute an offense is justifiable and
not criminal when it is necessary as an emergency measure to avoid an
imminent public or private injury which is about to occur by reason of
a situation occasioned or developed through no conduct of the actor,
and which is of sufficient gravity that, according to ordinary
standards of intelligence and morality, the desirability and urgency
of avoiding the injury clearly outweigh the desirability of avoiding
the injury sought to be prevented by the statute defining the offense
It isn't obviously immoral either (for the same reasons), although one could make a case that the "victim" could bring the tort of outrageous conduct a.k.a. intentional infliction of emotional distress, against the person causing it, although again, the question would be what were the damages and was it justified. The tort remedy is a better fit as it is often used in cases of "pranks" calculated to cause extreme emotional distress as this one apparently was. The intent of the "victim" to commit suicide might also constitute "unclean hands" barring a tort recovery in this situation in tort law if asserted by person A.