Open a program, then create a sticky note and then press Ctrl+Shift+W from within the sticky note. The sticky note will stick to the last active program window.
Alternatively, you can click on top left button over a sticky note and choose 'Stick To Window' option and then select which window you want the note to stick to. Then press OK.