Giving someone a drug without their consent can be considered infliction of bodily harm in various jurisdiction. When it caused a negative effect on the person the perpetrator did not anticipate, it might be grossly negligent (if that effect was likely to occur) or just negligent (if one could not reasonably expect that this effect would occur). Details depend on jurisdiction and the mood of the judge. It might also be a factor if the court rules that the defendant acted in bad faith (for example, by expecting that the drug would make the injured party consent to something they wouldn't have consented to otherwise, regardless of if this actually happened).
Additionally, if the intention was to cure the injured party from a medical ailment (as implied by "pill with beneficial effect") it could theoretically be possible that the perpetrator also gets charged for practicing medicine without a license (if that is illegal in the jurisdiction). Should the perpetrator have a medical license, they will likely get charged with medical malpractice, because in most jurisdictions it is illegal to treat a patient without their consent (if the patient is in a condition which makes informed consent possible).
Regarding adding something to your own drink and inadvertently poisoning someone else who drinks from it: In most societies, drinking from the glass of someone else is considered against social etiquette, so a possible defense could be that the perpetrator could not reasonably expect that the person would do that. But it could still be judged as infliction of bodily harm through negligence depending on the circumstances and how likely it was to happen. For example, in an environment where many glasses with similar-looking drinks stand on a table, the risk that glasses get mixed up is quite high. Details - again - depend on jurisdiction.