Thanks a lot for the tip. Entering the PID every time was a bit of a pain. So I think I found a better way.
I type : optirun bash from a console. For now on, every program run from that console will use optirun.
So I launch codeblocks from that console, and then I can debug a prog as usual, but this time running on the Nvidia card.