It is okay during sex, well at least in most jurisdictions. I will give you some helpful examples as far as I understand the law in Canada:
- If you consent to play a sport and get hurt in the normal course of that sport, does your consent to playing make the person who hurt you safe from criminal charges? YES. No assault. It is in the public interest to allow this type of consent or "implied consent" for potential injury.
- If you consent to a street fight and suffer bodily injury, does your consent make the other combatant safe from charges? NO. It is Assault. It is not in the public interest to allow this type of consent for injury.
- If you consent to BDSM and the infliction of pain upon your body for sexual gratification, is the other participant safe from charges? UNCLEAR. Most analysts would agree that if consent was explicit for all acts and there was no non-superficial "bodily harm" then there would be no assault. Previous Supreme Court Cases actually would make you believe that rough sex is NOT in the public interest so you cannot consent to be harmed during sex, but a modern re-trying of those principles would probably find that to be bad/outdated legal opinion.
- If you consent to being choked out and having vaginal sex performed on you while out, is the other participant liable? YES. This is assault under Canadian law. As soon as you lose the ability to withdraw consent at any moment, your consent is no longer valid.
- If you consent to "rough sex" and a dick ends up in your butt while you are passed out and that sex act was never specified, is the other participant in trouble? OF COURSE. There is no "implied consent" for anal rape or any other sex acts, really.