While there do appear to be some similarities between OCD and posttraumatic stress disorder (PTSD), there are also several differences.
First, PTSD has a defined trigger, a traumatic event that kicks it off, while OCD need not have a specific trigger that sets it off. Also, while PTSD does involve unwanted thoughts, often in the form of flashbacks or nightmares about the trauma, it is limited to the theme of the trauma.
OCD thoughts can run the gamut of themes and need not be related to anything traumatic that has actually happened. In fact, OCD thoughts are often about traumas that might happen instead of ones that have happened.
Further, there are avoidance behaviors often associated with PTSD, such as avoiding the place where a trauma occurred, but there are no compulsive behaviors that are associated with PTSD, as there are in OCD.