There are two parts to this question;
The 'when' is pretty easy to identify. He kind of notices her on the train on the way back to Hogwarts in Harry Potter and the Half-Blood Prince
‘Right,’ said Harry. He felt a strange twinge of annoyance as she
walked away, her long red hair dancing behind her. He had become so
used to her presence over the summer that he had almost forgotten that
Ginny did not hang around with him, Ron and Hermione while at school.
and is evidently thinking about her during his potions class (albeit he doesn't quite realise that the smell he's smelling is Ginny's perfume).
They chose the one nearest a gold-coloured cauldron that was emitting
one of the most seductive scents Harry had ever inhaled: somehow it
reminded him simultaneously of treacle tart, the woody smell of a
broomstick handle and something flowery he thought he might have
smelled at The Burrow.
and then again on their trip into Hogsmeade:
Harry’s thoughts strayed to Ginny as they trudged up the road to
Hogwarts through the frozen slush. They had not met up with her,
undoubtedly, thought Harry, because she and Dean were cosily closeted
in Madam Puddifoot’s teashop, that haunt of happy couples.
He realises that he's jealous of Dean:
however, they found themselves looking at Dean and Ginny, who were
locked in a close embrace and kissing fiercely as if glued together.
It was as though something large and scaly erupted into life in
Harry’s stomach, clawing at his insides: hot blood seemed to flood his
brain, so that all thought was extinguished, replaced by a savage urge
to jinx Dean into a jelly.
and then decides that he full on fancies her shortly afterward (and starts entertaining sexual fantasies about her):
But unbidden into his mind came an image of that same deserted
corridor with himself kissing Ginny instead … the monster in his chest
purred … but then he saw Ron ripping open the tapestry curtain and
drawing his wand on Harry, shouting things like ‘betrayal of trust’ …
‘supposed to be my friend’ [later] Harry gave a guilty start and wrenched his imagination away from a corridor in which no Ron intruded, in which he and Ginny were quite alone –
As to the why, it's clear that;
- He obviously finds her physically attractive
‘There’s the silver lining I’ve been looking for,’ she whispered, and
then she was kissing him as she had never kissed him before, and Harry
was kissing her back, and it was blissful oblivion, better than
Firewhisky; she was the only real thing in the world, Ginny, the feel
of her, one hand at her back and one in her long, sweet-smelling hair
– Deathly Hallows
Ginny and Gabrielle, both wearing golden dresses, looked even prettier than usual
He has become used to her company (see quote above)
He values her Quidditch skills
There are also a considerable number of quotes about the colour and length of her hair. Clearly he has a thing for gingers.