The story you describe is "The Eyes Have It" by Randall Garrett, first published in Analog Science Fact & Science Fiction, January 1964. The text is available at Project Gutenberg.
"Master Sean," said Lord Darcy, "there is still a mystery here. We need more evidence. What about the eyes?"
Master Sean blinked. "You mean the picture test, my lord?"
"It won't stand up in court, my lord," said the sorcerer.
"I'm aware of that," said Lord Darcy testily.
"Eye test?" Dr. Pateley asked blankly. "I don't believe I understand."
"It's not often used," said Master Sean. "It is a psychic phenomenon that sometimes occurs at the moment of death—especially a violent death. The violent emotional stress causes a sort of backfiring of the mind, if you see what I mean. As a result, the image in the mind of the dying person is returned to the retina. By using the proper sorcery, this image can be developed and the last thing the dead man saw can be brought out.
"But it's a difficult process even under the best of circumstances, and usually the conditions aren't right. In the first place, it doesn't always occur. It never occurs, for instance, when the person is expecting the attack. A man who is killed in a duel, or who is shot after facing the gun for several seconds, has time to adjust to the situation. Also, death must occur almost instantly. If he lingers, even for a few minutes, the effect is lost. And, naturally if the person's eyes are closed at the instant of death, nothing shows up."
"Count D'Evreux's eyes were open," Dr. Pateley said. "They were still open when we found him. How long after death does the image remain?"
"Until the cells of the retina die and lose their identity. Rarely more than twenty-four hours, usually much less."
"It hasn't been twenty-four hours yet," said Lord Darcy, "and there is a chance that the Count was taken completely by surprise."
"I must admit, my lord," Master Sean said thoughtfully, "that the conditions seem favorable. I shall attempt it. But don't put any hopes on it, my lord."
"I shan't. Just do your best, Master Sean. If there is a sorcerer in practice who can do the job, it is you."
"Thank you, my lord. I'll get busy on it right away," said the sorcerer with a subdued glow of pride.
"The Eyes Have It" is the first story in Garrett's Lord Darcy series, about a magical detective in an alternate Europe. From Wikipedia:
Lord Darcy is a detective in an alternate history, created by Randall Garrett. The first stories were asserted to take place in the same year as they were published, but in a world with an alternate history that is different from our own and that is governed by the rules of magic rather than the rules of physics. Despite the magical trappings, the Lord Darcy stories play fair as whodunnits; magic is never used to "cheat" a solution, and indeed, the mundane explanation is often obscured by the leap to assume a magical cause.
Lord Darcy is the Chief Forensic Investigator or Chief Criminal Investigator for the Duke of Normandy (Prince Richard, the brother of the king), and sometime Special Investigator for the High Court of Chivalry. An Englishman, he lives in Rouen, but spends very little time there. We are told that he speaks Anglo-French with an English accent, and that he speaks several languages and dialects fluently.
His full name is never given; he is always referred to by his title as the Lord of Arcy (i.e., Lord d'Arcy or Lord Darcy), even by his friends. He dresses in the style of an English aristocrat. He thinks of himself as English and yet Arcy seems to be a French place name. How he comes to be addressed as a "Lord" is never explained, though he seems deferential when dealing with other Peers such as Dukes, Counts, and a Marquis. In Too Many Magicians Darcy is said to be a cousin of the Marquis of London.
There are two conflicting reports of Lord Darcy's age. In "The Muddle of the Woad" he's described as a few years older than the King, who's ten years older than the Duke of Normandy, who was 19 years old in "The Eyes Have It", which is set in 1963. This places Lord Darcy's date of birth around 1931. However, he's described in "The Spell of War" as an 18-year-old lieutenant in the autumn of the War of '39, which would make him about ten years older.
His assistant is Master Sean O Lochlainn, a sorcerer who undertakes magical forensic work. Master Sean is highly proud of Irish magic and its superiority to those of other countries (especially to Polish magic).
Frozen Retinal Images in Fiction and Folklore
The idea of a retinal image persisting after death seems to come from folklore. In comments, b_jonas provides a TV Tropes Link and remarks that this idea was used by Jules Verne in his 1902 novel Les Frères Kip. Before that, it was used in Cleveland Moffett's short story "On the Turn of a Coin" which was published in the April 1900 issue of The Black Cat. Quoting Everett F. Bleiler's review of Moffett's story in Science-Fiction: The Early Years:
Young Marie Gagnol has been brutally murdered by a man who invaded her apartment. Dr. Rousseau contributes to identifying the murderer by photographing the dead woman's retina and developing the death-image that is frozen there.
The story is based on a common belief of the day, that a dead person's eyes retained an image of the last thing seen.
A still earlier work touching on this theme, suggested by b_jonas, is Rudyard Kipling's 1890 short story "At the End of the Passage", available at Wikisource.