Sometimes it's 'some times', but it'll be 'some time' sometime

I was recently caught off guard when asked what the difference between ‘sometimes’ and ‘some times’ is, and when you should use one or the other.  My response was vague at best, so I’m hopefully going to make it a bit clearer here.

Sometimes is an adverb, and should be used to mean ‘occasionally’ or ‘at times’, and can be used in any case where a frequency is neither never nor always.

I sometimes go to the gym on Wednesdays.
Sometimes I have tacos for dinner.

Some times should be used as a noun phrase, that is when using ‘time’ as a noun.

The doctor gave me some times when I could come in for an appointment.
There were some times last week when it rained really hard.

Sometime is used as an adverb, meaning ‘at an indefinite point in time’ (in the future or the past).  It is also occasionally used as an adjective meaning ‘having been once’, or ‘occasional’.

We should meet for coffee sometime.
His flight arrives sometime next week.
He was away a lot, so could only be a sometime boyfriend.  

Some time is used as a noun phrase, describing a period of time with no definite length.

It took some time to finish the project.
Some time ago, I went on holiday to Paris.

As far as pronunciation goes, sometimes and sometime have slightly more emphasis on ‘some’, and some times and some time have ‘time’ stressed.