As I understand, it's partly random.
A Pokemon has a 50% chance of using one of it's charge moves, assuming it has gained sufficient energy. So if a defender both has a high energy move (e.g. a one-bar move like Solar Beam) and a low energy move (e.g. a three-bar move like Seed Bomb), then the latter should theoretically get used more often. With two equal energy charge moves, it should be entirely random.