Your son is very insecure just now. He went through what was, in his young and developing mind, a traumatic experience with the rock-in-ear problem, and it happened just at a time when many if not most kids get clingy anyway. Combine those two things and it adds up to a boy who's insecure just now and really, really just wants to know mom and dad are RIGHT HERE for him. The fact he's able to go to school just fine is a big, big positive, and be sure to praise him for that a lot every day.
But as for the bedtime--I'm with the pediatrician for now. If there hadn't been the ear trauma, I'd say yes, quietly and firmly just return him to his room every time he comes into yours, even if it takes a dozen times a night until he understands where he has to sleep. However, right now this isn't about disciplining him or teaching him firm bedtime boundaries; it's about his fears, which seem to be based in a real and painful event. So for a while longer, I'd let him wander in. You can try returning him to bed the first few times, but don't scold or engage him and if he comes back to the floor, you could let him lie down but say nothing, then pick him up once he's asleep and return him to his bed so he's waking up there every morning; then remind him in the a.m. that it's great to have his own room. But if he was really upset by the rock incident, I'd give him more time. He will not be on your carpet when he's fourteen, or even when he's four. I should say here, I'm a big fan of the "return them to bed" routine so kids do learn not to invade the parental bed, but there's more going on here.
Also, does he talk about fears? Does he think the rock will come back somehow, or that the doctor is someone who hurts him and he dreads going there? Does he seem to be having nightmares when in his room? This is also a classic age for fears and nightmares, and again, combined with the ear thing, that could be an issue -- he may associate his room with bad dreams, painful nights with the ear, strange shadowy shapes (even with a night-light, kids can see a lot of weird stuff in their rooms at night!), etc. He may not ever tell you this verbally; many kids don't.
I would not shut myself in his room without him and tell him you're going to use his bed since he isn't. If he were wilfully just testing his boundaries by not going to bed that might work, I guess, but since it sounds like real fear is at play here, I think it would upset him further and make him more, not less, insecure if you lock him on the other side of a gate from you. He's still very young and the key here seems to be that he started this behavior immediately after a painful event. Give him some time.
And as for breathing -- once he's asleep on the floor, elevate his head with a small firm pillow. He won't freeze at night, either; put him into warmer pajamas. If he's still doing it in a few weeks, reassess, and always try talking to his preschool teacher about ideas too. Good luck and tell us what happens.