When I went to visit, he wasn't there.

Literal

I [subject-が] visit-go-[when-た-時] he [topic-は] absent was.

訪ねて行く combines 訪ねる ('to visit') with 行く ('to go') via te-form — 'visit-going' = 'went to visit.' 時 ('time, when') attaches to a past-tense clause to express 'when [X] happened.' 不在 ('absent, not present') is a formal noun used as a predicate with the copula. A slightly elevated register for a simple situation.