I think I understand what you mean, because I've had similar experiences and now believe that it's connected to my anxiety.
It might not be the exact same thing, but this is my experience. Sometimes when I get very stressed out (or am forced to be social for much longer than I'm comfortable with) I kind of 'withdraw' into my own head. That's the best I can describe it. It's like I'm observing what's happening around me, but it feels a bit like a dream. I'm watching everything happening without really being there. I listen to myself talk, listen to the words that are coming out of my own mouth without realising or really controlling what I'm saying.
Only it's different from being drunk. I know exactly what's happening around me, it's just no longer 'real' and I'm not fully there anymore. I'm detached.
The first time this happened, I thought I might be going mad
But it's happened a few times since and it doesn't really bother me. It's not particularly scary, just a bit disorientating. This only lasts for very brief periods of time anyway; somewhere between 5-20 seconds, for me. I blink myself out of it and regain focus pretty easily. I did a little research into this and yes, I think this is 'derealisation'. When I read through the symptoms, it matched what I've experienced. I'm not a doctor or psychiatrist or anything, so I'm essentially self-diagnosing this experience. But it's supposedly a coping mechanism for bouts of anxiety, so I think it makes sense.
If you're interested, try typing 'derealisation and anxiety' into Google and take a look at what comes up.
Hope this helped