'When' is used to show that something is certainly going to happen.
'If' is used to show something may or may not happen. If shows uncertainty.
'When' and 'If' can also be used interchangeably when the outcome is predictable and repetitive.
Both these sentences effectively mean the same thing. In such conditions both these words can be used interchangeably.
Doubts on this article