Harry has Defence Against the Dark Arts classes in The Philosophers Stone with Quirrell, but his scar never hurts despite being in such close proximity to Voldemort... Why?
Harry's scar hurt when Voldemort was feeling a particularly strong emotion. Distance didn't seem to make much difference - Harry even felt Voldemort's thoughts when the latter was off chasing the Elder Wand in another country. During the DADA classes Voldemort was keeping quiet and waiting for his plan to bear fruit, so he didn't feel anything strong enough to affect Harry's scar.
Harry's scar became more active in later books, at least partly because Voldemort was becoming more powerful and plotting against Harry more often. It might also be that the connection strengthened with use and/or Harry became more sensitive to it as he matured. Harry being young and inexperienced, and Voldemort living half a life with no body of his own, might have weakened the connection during PS.
It only hurt initially when they looked at their turban where Voldemort was hiding.
It happened very suddenly. The hook-nosed teacher looked past Quirrell’s turban straight into Harry’s eyes – and a sharp, hot pain shot across the scar on Harry’s forehead.
‘Ouch!’ Harry clapped a hand to his head.
‘What is it?’ asked Percy.
The pain had gone as quickly as it had come. Harder to shake off was the feeling Harry had got from the teacher’s look – a feeling that he didn’t like Harry at all.
Presumably they didn't stare at Voldemort's turban before then or Voldemort was feeling unemotional because he didn't care about DADA class theory.
Voldemort then looked at them face to face.
Malfoy let out a terrible scream and bolted – so did Fang. The hooded figure raised its head and looked right at Harry – unicorn blood was dribbling down its front. It got to its feet and came swiftly towards him – he couldn’t move for fear.
Then a pain pierced his head like he’d never felt before, it was as though his scar was on fire – half-blinded, he staggered backwards. He heard hooves behind him, galloping, and something jumped clean over him, charging at the figure.
His scar then just hurt all the time, likely because of the emotional connection from eye to eye contact.
Harry did the best he could, trying to ignore the stabbing pains in his forehead which had been bothering him ever since his trip into the Forest. Neville thought Harry had a bad case of exam nerves because Harry couldn’t sleep, but the truth was that Harry kept being woken by his old nightmare, except that it was now worse than ever because there was a hooded figure dripping blood in it.