Often the grammar of the sentence determines the one-word/two-word difference for the word sometime.
If it is the object of a preposition, it has to be two words.
…for some time…
…at some time…
In these expressions, the word time is the main noun. You cannot say “ago” or “back” by themselves. So you need two words.
…some time ago…
…some time back…
Often when you can remove the word some, you want two words because time is the main word.
…I spent some time with her last week.
…There was some time between the two visits.
Sometime, as one word, means an indefinite POINT in time; some time, as two words, means an indefinite PERIOD of time.
…We left sometime later.
…I will see you sometime after she leaves for work.