I want to know which of these is correct
When did Rob leave for office?
Or
When did Rob leave to office?
Neither are correct, as you're missing a word. With the word "the" I would expect the former:
When did Rob leave for the office?
You leave for somewhere. You can also leave to do something:
When did Rob leave to find the office?
The choice of preposition often depends on the particular word (verb or adjective) that governs the phrase; unfortunately there is little logic or pattern to these. So
Go takes a to phrase, and can take a from phrase
Come takes a from phrase, and can take a to phrase
Leave takes a direct object (the place left) and takes a for phrase (the destination). It can also take a from phrase, typically specifying more precisely than the direct object where the journey starts.
Arrive takes an at phrase, and can take a from phrase
So When did Rob leave for the office? is grammatical and natural.
Leave, a verb, means to go away from someone or something.
We generally may go away to do something [perform, such as, to skydive, to drive, to play, etc.(verbs)] or, toward something [a location, such as, a country, a park, etc.(nouns)]. And, since the object(office) in your example is indeed a noun, the only possible preposition can be for
.
Thus,
When did Rob leave for the office?
Yes, the article the before office is imperative, to signify that specific place.