You will need to use silicone sealant to fill the gaps between frame and door/window. First figure out where the gaps are larger first; you will be putting more sealant on the frame around those points. Then rub a thin film of vaseline into the parts of the door/window that close against the frame. Squirt desired amounts of sealant onto the frame so that when you close the door or window, there are no gaps and there is a snug fit.
Leave the door/window shut for the recommended time to let the sealant dry (printed on the sealant tube); then, when you open it, the vaseline should have ensured that there is no sticking!
Caution Use your own judgement when following these instructions. If you apply too much sealant then you may find it squeezing out and sticking the frame to the door or window. Make sure that you use enough vaseline - it's better to use more!
Cathy Debenham of YouGen has covered this technique too: The best way to draught-proof an old window or door.