In S5E5 (when Patrick Jane first meets the CBI team and joins them), Virgil is insistent on allowing Jane to follow Lisben around. Red John wants Jane on the Red John case, so he is using Virgil (or is Virgil) to make sure that Jane (who has no police experience) has an opportunity to take part in the Red John case. The reasons Virgil gives for allowing Jane to follow Lisben around are pretty hollow. During the end of the episode, he also agrees (almost too willingly) to provide the FBI with information about Jane. If Virgil is Red John, he uses his position in the CBI to watch Jane, while also providing information about Jane to the FBI, where he can gain favours from them for helping them. The ending shows that Virgil (along with the lady from the FBI) is a part of this somehow.