There is no correct moment, and anyone insisting otherwise is describing their own preference. What exists is a trade-off: disclosing early costs less when it goes badly but reveals more to people you barely know, and disclosing later means more invested on both sides.
The case for very early
Putting it in a profile or raising it in the first exchange means nobody withdraws after you have built anything. Rejection at that stage costs almost nothing emotionally, and you never sit through an evening knowing a conversation is coming. For people who find repeated disclosure draining, this removes the whole cycle.
The case for before meeting
A message before you travel keeps it out of a public profile while still handling it before anyone has invested time. It gives the other person space to look something up and reply considered rather than reacting on the spot. Most people who disclose regularly settle somewhere around here.
The case for before sex
The point at which it becomes relevant to what you are both doing, and the latest point most people would consider reasonable. The risk is that it arrives when both of you are already committed to the evening, which is not the ideal moment for anyone to absorb new information.
The case for later
Some people wait until there is enough between them for the other person to hear it as one fact about someone they like rather than as a defining feature of a stranger. That works, and it means the eventual rejection, if it comes, lands considerably harder.
Does it depend on what you are disclosing?
Somewhat. An undetectable viral load carries no transmission risk, so the timing is about honesty and comfort rather than about anyone's safety. Herpes involves a real if modest transmission risk, which pushes most people towards before sex. A current untreated infection means not having sex at all until it is treated, which settles the timing question.
Does it depend on the kind of encounter?
Yes, and treating casual and ongoing situations identically makes both harder. Many people disclose to anyone they see more than once and not to casual encounters where nothing else about health is discussed. That is a coherent position rather than an inconsistency.
What is worth avoiding?
Deciding in the moment. Whatever you choose, choosing it in advance means you are not weighing it while someone is undressing. People who have a settled approach report the conversations going considerably better, largely because certainty is easier to hear than hesitation.
What about the person on the other side?
If someone tells you late, the useful reaction is to ask why they waited rather than assuming the worst. Usually the answer is that they have been rejected before and were trying to be known first. That is not deception; it is self-protection.
Does it differ for casual and ongoing encounters?
Considerably, and treating them the same makes both harder. For a single casual encounter, before sex is the latest reasonable point and before meeting is easier. For anything that might become ongoing, most people find that early is better, because the cost of a late disclosure rises with everything built on it.
The practical version
Pick a point, use it consistently, and adjust it if it stops working. Any of the options above is defensible, and having one is better than deciding each time.
Does the setting matter?
Yes. Somewhere private, with time, and where either of you can leave. Raising it as you walk into a bedroom, or in a crowded bar, both go worse than a quiet conversation or a written message. The place is part of the timing.
What if you keep putting it off?
A signal to move it earlier rather than to keep delaying. Deferred disclosure becomes progressively harder as more is invested, and it also risks the other person hearing it as something withheld. Setting a rule for yourself removes the repeated decision.
Does anyone get this right first time?
Rarely. Most people try several approaches before settling on one, and the early ones going badly is normal rather than evidence you handled it wrong.