Two years ago my ex-wife and I separated.
My ex-wife and I separated two years ago.
These two sentences essentially mean the same thing. The adverbs of time are flexible. They can be either placed at the beginning of the sentence or at the end of the sentences.
Note: As said by Kate Bunting, you should just use 'wife' instead of 'ex-wife', unless you are intending to say that she was your wife at some point in the past, you had separated and then again came together, and now again separated, which is highly unusual to say.
My ex-wife and I got separated two years ago.
This would mean some external factor or influence caused your separation from your wife. This is different from the above two sentences. You can even rephrase this sentence in a similar manner as the previous pair.
Two years ago my wife and I got separated.