Option B is correct grammatically, and strictly speaking, it's correct semantically when taken literally, but it's not what English speakers say.
when has the connotation of 'because' here. Besides, when connotes a more immediate temporal connection between the two events when compared with after, which is more vague temporally. (How long after? Soon after? or Qui