From PIE *kwom (at what point), cognate with Latin 'quando' — its counterpart 'then' also produced 'than.'
At what time; at or during the time that; in the event that.
From Old English 'hwenne' or 'hwanne' (when, at what time), from Proto-Germanic *hwanna, from PIE *kwo- (interrogative-relative pronoun stem), the source of virtually all interrogative words in Indo-European languages. This single PIE root generated the entire English 'wh-' question series: 'who' (*kwo-), 'what' (*kwod), 'where' (*kwor), 'when' (*kwo- + temporal suffix), 'why' (*kwi-), 'which,' 'whether,' 'whence,' and 'while.' The initial 'hw-' cluster in Old English (reflecting the Proto-Germanic *hw-) was spelled 'hw-' before being reversed
'When' and 'than' are the same word. Old English used 'þonne' to mean both 'then' (at that time) and 'than' (compared to). 'Than' split off as a separate word in Middle English, but it is historically just the demonstrative counterpart to the interrogative 'when' — 'at what point' answered by 'at that point' became 'compared to that point.'