A flag is usually a boolean variable that you set to debug your program. This is useful if you want know if your program has reached a certain point or subprogram. So you might start off setting the flag to false, and in a subprogram set it to true. Then have a breakpoint after the subprogram, then you can check if the flag is true/false and you would know if that particular subprogram was executed.
A stub in the otherhand is a 'fake' subprogram. It doesn't actually do any processing, it just returns the values that it would otherwise if it was actually written. This lets you test other part of the program that require this module without actually having to write it, it might also given some message to the programmer to let them know that the stub was executed.