Are you using call graph or sampling? If you are using sampling it is system wide so you can just tell VTune to launch program B or not to launch anything at all. It will collect system wide information so you should see profiling data for program A and B. If you are using call graph tell call graph to launch program B. Then in the modules of intersest window remove program B and add program A.
In addition to what Birju said, for call graph you can tell to run nothing and then in the modules of interest window add program A. If you will choose this way, do not forget to press Stop button after program A will finish.