Roger is pretty good friends with George (and formerly Fred) from Hogwarts and spent some time at the Burrow in the summers. I'm sure he ran into Hermione from time to time during his stay. Of course he would be polite with her, and probably likes to get into friendly 'whose smarter' matches on random subjects; you know those Ravenclaws just can't resist.