It was just a coincidence.
Voldemort is planning the escape of his key lieutenants from Azkhaban and is alternately happy and frustrated. Those strong emotions make Harry's scar tingle. He also feels a similar pain when getting changed after Quidditch in Chapter 18.
‘What happened?’ said Ron, the moment Alicia had disappeared through
the door. ‘Was it your scar?’ Harry nodded. ‘But …’ looking scared,
Ron strode across to the window and stared out into the rain, ‘he – he
can’t be near us now, can he?’ ‘No,’ Harry muttered, sinking on to a
bench and rubbing his forehead. ‘He’s probably miles away. It hurt
because … he’s … angry.’
A confused tangle of shapes, a howling rush of voices … ‘He wants
something done, and it’s not happening fast enough,’ he said. Again,
he felt surprised to hear the words coming out of his mouth, and yet
was quite certain they were true.
‘Is this what it was about last time?’ said Ron in a hushed voice.
‘When your scar hurt in Umbridge’s office? You-Know-Who was angry?’
Harry shook his head.
‘What is it, then?’
Harry was thinking himself back. He had been looking into Umbridge’s
face … his scar had hurt … and he had had that odd feeling in his
stomach … a strange, leaping feeling … a happy feeling … but of
course, he had not recognised it for what it was, as he had been
feeling so miserable himself …
‘Last time, it was because he was pleased,’ he said. ‘Really pleased.
He thought … something good was going to happen. And the night before
we came back to Hogwarts …’ he thought back
Ron later identifies (in chapter 25) what kept making Voldemort so frustrated/happy;
"The Ministry of Magic announced late last night that there has been
a mass breakout from Azkaban. Speaking to reporters in his private
office, Cornelius Fudge, Minister for Magic, confirmed that ten
high-security prisoners escaped in the early hours of yesterday
evening and that he has already informed the Muggle Prime Minister of
the dangerous nature of these individuals.
‘There you are, Harry,’ said Ron, looking awestruck. ‘That’s why he
was happy last night.’"