Unless you tell the doctor you had sex he won't know. Sex doesn't magically change the penis in a way that is noticable by a doctor. And even then, even if the doctor could tell unless he thought you were a danger to yourself or someone else he'd keep any such medical information confidential.