Voldemort already knew he planned on making 7 Horcruxes - he asked Slughorn specifically about 7 and also the rocks on his window. So, why didn't he know Harry was one? Or surely he knew Harry would end up becoming one, inevitably meaning that he would die in the battle and life was pointless?
Harry becoming a Horcrux was a fluke that Voldemort did not foresee.
First of all Voldemort only ever intended to make six Horcruxes, not seven. In Chapter Twenty-Three of Half-Blood Prince we see him express his desire for a seven-part soul:
"Yes, sir," said Riddle. "What I don't understand, though — just out of curiosity — I mean, would one Horcrux be much use? Can you only split your soul once? Wouldn't it be better, make you stronger, to have your soul in more pieces, I mean, for instance, isn't seven the most powerfully magical number, wouldn't seven — ?"
Dumbledore then clarifies that this means six parts in addition to the original part that would remain in his body:
"He made seven Horcruxes?" said Harry, horror-struck, while several of the portraits on the walls made similar noises of shock mid outrage. "But they could be anywhere in the world — hidden — buried or invisible —"
"I am glad to see you appreciate the magnitude of the problem," said Dumbledore calmly. "But firstly, no, Harry, not seven Horcruxes: six. The seventh part of his soul, however maimed, resides inside his regenerated body. That was the part of him that lived a spectral existence for so many years during his exile; without that, he has no self at all. That seventh piece of soul will be the last that anybody wishing to kill Voldemort must attack — the piece that lives in his body."
It happens to be that Voldemort only had five Horcruxes (plus the original) when he tried to kill Harry the first time, and he only made the sixth Horcrux after he regained his body:
"I don't think so," said Dumbledore. "I think I know what the sixth Horcrux is. I wonder what you will say when I confess that I have been curious for a while about the behavior of the snake, Nagini?'
"The snake?" said Harry, startled. "You can use animals as Horcruxes?"
"Well, it is inadvisable to do so," said Dumbledore, "because to confide a part of your soul to something that can think and move for itself is obviously a very risky business. However, if my calculations are correct, Voldemort was still at least one Horcrux short of his goal of six when he entered your parents' house with the intention of killing you. He seems to have reserved the process of making Horcruxes for particularly significant deaths. You would certainly have been that. He believed that in killing you, he was destroying the danger the prophecy had outlined. He believed he was making himself invincible. I am sure that he was intending to make his final Horcrux with your death. As we know, he failed. After an interval of some years, however, he used Nagini to kill an old Muggle man, and it might then have occurred to him to turn her into his last Horcrux. She underlines the Slytherin connection, which enhances Lord Voldemorts mystique; I think he is perhaps as fond of her as he can be of anything; he certainly likes to keep her close, and he seems to have an unusual amount of control over her, even for a Parselmouth."
The part where Harry became a Horcrux was not intended and it was never supposed to happen. In Chapter Thirty-Five of Deathly Hallows Dumbledore describes it to Harry as follows:
“You were the seventh Horcrux, Harry, the Horcrux he never meant to make. He had rendered his soul so unstable that it broke apart when he committed those acts of unspeakable evil, the murder of your parents, the attempted killing of a child. But what escaped from that room was even less than he knew. He left more than his body behind. He left part of himself latched to you, the would-be victim who had survived.
Voldemort never knew about this because this was unprecedented. No one had ever split their soul so much that it became unstable enough to split up without the owner's desire. As Dumbledore said back in Chapter Twenty-Three of Half-Blood Prince (my emphasis):
Then you told me, two years later, that on the night that Voldemort returned to his body, he made a most illuminating and alarming statement to his Death Eaters. ‘I who have gone further than anybody along the path that leads to immortality.’ That was what you told me he said. 'Further than anybody!' And I thought I knew what that meant, though the Death Eaters did not. He was referring to his Horcruxes, Horcruxes in the plural, Harry, which I don’t believe any other wizard has ever had.