Raf got hit with the Dark Energon because he was riding inside Bumblebee. Though it doesn't seem like it, 'Bee is also affected to a lesser degree. He is presumably just "putting on a brave face" for Rafs sake, as Optimus tells Arcee to look after Raf and Bumblebee when sending them back to base. Plus, a point brought up in some discussions on the final episode, 'Bee directly handled a shard of Dark Energon when he was being possessed by Megatron in Out of his Head. It would be fair to assume that this allowed him to develop a minor immunity to its effects.