The prime minister said these people were not benefiting from treatment and were increasing the risk of passing the virus on to others.
The Health Protection Agency said about 600 people were dying needlessly from the condition each year.
Its figures have been released to coincide with World Aids Day.
Mr Cameron said the event should be used to "spread the message" about education, testing and early diagnosis.
"World Aids Day is a chance to do two things - take action and reflect," he said.
"First and foremost, it's got to be a spur to take action, as there are still far too many people who aren't educated about HIV and Aids and who don't get tested.
HIV stands for human immunodeficiency virus and on its own it does not kill you.
The virus can survive and grow only by infecting, and destroying, the immune system.
This continual assault on the immune system makes it weaker and weaker until it is no longer able to fight off infections.
Without treatment, it takes about 10 years from infection to the development of Aids - acquired immune deficiency syndrome.
It is then that "opportunistic infections", ones a healthy immune system could fight off, become deadly.
People can die from pneumonias, brain infections, diarrhoeal illnesses, as well as certain tumours such as lymphoma and cervical cancer.
BBC Health: HIV and Aids
"People need to know that, diagnosed early, the outlook for most people with HIV in the UK today is a good one, thanks to the availability of effective treatment and the excellent care provided by the NHS.
"Above all, people need to know that it's never been quicker or simpler to get tested."
The Health Protection Agency (HPA) said its figures suggested about 100,000 people in the UK were currently living with HIV, but about a quarter of them did not know they had the virus, which untreated can lead to the development of Aids.
The figures also showed that more than 6,000 people in the UK were diagnosed with HIV last year.
Among men, the figure of more than 3,000 diagnoses was an all-time high.
Lisa Power, from the Terrence Higgins Trust charity, said fear was stopping some people getting tested, but they were much better off knowing if they had HIV.
She said: "It's extremely alarming that so many people in the UK have HIV but are undiagnosed.
"Nowadays, if you get tested, get diagnosed and get on the treatment at the right time, you can live to a ripe old age. You'll live into your 70s, maybe even your 80s.
"But, if you don't know that you have it... then you could become very ill before you're diagnosed and then the pills won't work as well."
She said a shortage of money available to the trust meant it had to target the most at-risk groups, adding: "What's happened over the last decade or so, there has been very little awareness of HIV and sexual health among the general population."
To mark World Aids Day, the World Health Organization (WHO) issued a statement on global progress on cutting new infections and Aids-related deaths.
In 2011, there were 2.5 million new infections - down 700,000 from the 2001 figure - and an estimated 1.7 million people died from Aids-related illnesses. That was 600,000 fewer than in 2005.
The WHO said improving access to antiretroviral drugs was key to cutting rates further.

South Yorkshire PC Lee Lucas, 39, of Prince of Wales Road, Sheffield, also sent "suggestive and flirtatious" messages to vulnerable women.
He admitted eight counts of making indecent images and one of misconduct in a public office at a previous hearing at Sheffield Crown Court.
Lucas shared thousands of messages with eight women during 2013.
The women, some of which were also visited by Lucas, had contacted the force in relation to various incidents including harassment and domestic abuse, the court heard previously.
Lucas, who has been a PC with the force since 2010 and was based at Rotherham Police Station, was found to have had "excessive and unexplained contact" with the women after an internal investigation.
The inquiry also led police to discover he had 1,400 indecent images of children on his computer, the force said.
He was suspended by the force in October following his conviction.
Terry Mann, head of professional standards at South Yorkshire Police, said: "I would like to reassure the public that Lucas was the most serious case out of a very small number of officers who made improper contact with such victims.
"They have all now been dealt with."
There is still too much ignorance about HIV and Aids, David Cameron has said, as figures suggest 25,000 people in the UK have the virus but do not know.
[NEXT_CONCEPT]
A police officer who admitted making 1,400 indecent images of children has been jailed for 12 months.