Long (and, in case of Warlock, also short) rest allows you to restore the spellslots, and in 5e has nothing to do with swapping spells, thankfully.

RAW it's more restricted, I believe, you can only do it during the rest (any rest). However, with BG3 being what it is, here you can do it at any time outside of combat.