By the way, when agitated, Ann’s a pest! (2,7)
I believe the answer is:
en passant
'by the way' is the definition.
(I've seen this before)
'agitated ann's a pest' is the wordplay.
'agitated' indicates anagramming the letters.
'anns'+'a'+'pest'='annsapest'
'annsapest' with letters rearranged gives 'EN PASSANT'.
'when' is the link.
(Other definitions for en passant that I've seen before include "An aptness, by the way, for chess move" , "Way of capturing pawn" , "In passing like chess move" , "Incidentally, in the course of doing something else" , "Term used on board" .)