Depersonalization is a feeling of being disconnected or detached from your body and your thoughts. It has been described as a feeling that you're observing yourself from outside your body. Episodes of it can be brief, lasting just a few minutes, or can continue or recur for years. Affected individuals don't lose contact with reality. With derealization disorder, you perceive your surroundings as unreal. Both of these conditions tend to occur with anxiety disorders. When they do not, they're described as "dissociative disorders" and are currently attributed to extreme stress or trauma during childhood. There may be a genetic component, however, because dissociative disorders seem to run in families.
I assume that you are suffering from some variant of panic disorder, and I discussed your question with an expert, psychiatrist Bernard Beitman, M.D., formerly chair of the Department of Psychiatry at the University of Missouri-Columbia's medical school. He explained that the common triggers of panic attacks, which can include feelings of depersonalization and derealization, are phobic reactions to physical sensations (for example, fear that chest pain means that you're having a heart attack); separation/abandonment fears triggered by minor events; and fear of one's own anger. (There are many other triggers.) Dr. Beitman says that the best way to determine your own particular triggers is to keep a diary in which you note (1) the situation in which the symptoms occur; (2) the thoughts that accompany them; and (3) any accompanying emotions. A complete list of triggers can help you identify the underlying fears, which then can be confronted.
Dr. Beitman also suggests that you read one of the many excellent self-help books on panic disorder. He particularly recommends the very popular, well-researched approach in books by psychology professor David Barlow, Ph.D. and clinical psychologist Michelle Craske, Ph.D., but notes that there are many other approaches involving more direct cognitive therapy, some that use insight meditation and some based on Freudian theory.
My top recommendation for dealing with anxiety and panic disorder is my relaxing breath. I recommend several other drug-free ways to treat anxiety (see: Ending Anxiety With Brainwave Music Therapy?).
Andrew Weil, M.D.