Hello Marie Ni,
" I go swimming when I have time"
"when" used as a conjunction has the same meaning of "if" and is almost interchangeable with it.
It means here I go swimming in the event that, provided that I have time. In this sense it is the same like saying " I go swimming if I have time".
"When" could also mean " at what time " or " at or during which time" ," the time or occasion at in which something could happen".
So it means then that i go swimming at those times when I am free and have the time to do it .
Here that would be an answer to " When do you go swimming usually?".
In this case it has another distinct meaning and is not interchangeable with " if I have time"