I'm a novice in music theory. I was just improvising over a C-B7 progression and I can play the E harmonic minor and also Em pentatonic scale over this progression. What mode would they be if we take C and B as the root in each case?
I'm a little unclear on what you're asking, but I'll approach your question from a couple different ways:
C and B7 are diatonic in E harmonic minor. By diatonic, I mean that these two chords exist in E harmonic minor without the use of any extra accidentals. As such, an E harmonic minor scale will work very well over these two chords, as you've noticed.
If you're asking about the modes of these C and B scales built in E harmonic minor, they would be the B Phrygian dominant and C Lydian ♯2.
The B is Phrygian dominant because it has the stereotypical Phrygian note of ♭2 (in this case, C♮ instead of C♯), and the "dominant" modifier indicates that the B triad will be major on account of the D♯.
The C is Lydian ♯2 because, in addition to the ♯4 (F♯) we expect in Lydian, it also has D♯.
Note that the E minor pentatonic (assuming you mean Read the very helpful comments below regarding this sentence; I was completely wrong, and I learned something new!
E G A B D E) is not quite ideal above the B chord, since the D♮ of the pentatonic will clash with the D♯ of the B chord.
I agree with everything in Richard's fine answer. If the second chord is being voiced/heard as B7alt, then E minor pentatonic licks will sound great over the two chords (in moderation) because the D♮ is the ♯9 of B7alt. Assuming the song is in E minor, then E minor pentatonic would be a very common choice of scale to improvise with. E minor blues licks would be common and would sound great too. That said, if you spend too much time improvising with E minor pentatonic, you risk the solo sounding harmonically weak. For harmonic variety, you could move back and forth between (a) E minor pentatonic and (b) outlining etc. the chords.
In addition to thinking of the song as being in E harmonic minor, there is another (less common) alternative. You can also think of the progression as being in C Maj, so that the B7 chord is a tritone substitution for F7. This would lead to playing C Ionian followed by F Altered, F Phyrgian Dominant, F Lydian Dominant, or F half-whole diminished. Under this approach, it's usually much harder to get the solo lines to resolve back to C Maj, because the ear won't be drawn to a strong tonal center like E minor. If you take this approach, it might be valuable to do some targeted practice on how to resolve your lines from B7 back to C. On these progressions, I've always found it easier to resolve from B7 to C by using F half-whole diminished over the B7 chord. But some people understandably feel that the diminished scale sounds overly mechanical/artificial, especially if used in large amounts.
In most scenarios, it will make more sense to think of this progression as being in E minor (a ♭VI-V7 progression). The alternative (thinking of it as a I-IV7alt progression in C) is less common, but it does occur in some songs.