The earliest English-language example I know of is "The Head" by Joe Kleier, a short story in Amazing Stories, August 1928, available at the Internet Archive. The following review is quoted from Science-Fiction: The Gernsback Years by Everett F. Bleiler (ISFDB, Wikipedia):
Short story. * Dr. Leeson makes a strange offer to Beardsley, who is dying of cancer. Leeson has developed the technique for keeping a severed head alive apart from its body: artificial blood and elaborate machinery, carefully attended perpetually by two assistants. And he wants to buy Beardsley's head. * At first Beardsley is shocked, but when Leeson offers him fifty thousand dollars to provide for his young daughter, Beardsley accepts. * The conditions are that Beardsley will stay alive for two months; if after that, he desires death, Leeson will fulfill his wishes. If Beardsley makes no signal, he will also be put to death at that time. * The operation proceeds successfully, but Leeson is killed in an automobile accident almost immediately afterwards, and the Beardsley situation receives much publicity. Legal action against Leeson's assistants fails, since Beardsley is not dead and had consented to the operation; and no one can take the responsibility of releasing him. * Time passes, during which the head is cared for. A religious cult arises around it, and its facial movements are taken as oracles. Not until years later, during a war, is the head destroyed by an invader.
An earlier example from Russia is Professor Dowell's Head aka The Head of Professor Dowell by Alexander Beliaev (ISFDB, Wikipedia) (transliterated variously), originally published in Russian in 1925 as Голова профессора Доуэля (Golova professora Douela). The following is extracted from a long review in Science-Fiction: The Early Years by Everett F. Bleiler (ISFDB, Wikipedia):
When young Marie Laurent, apparently a qualified physician, applies for a job with Professor Kern, she certainly does not anticipate what will follow. Kern specializes in maintaining life in detached human organs, and, indeed, in his laboratory maintains the living severed head of his old mentor and teacher, Professor Dowell, an English savant. The head is hooked up to a fairly elaborate support apparatus, which includes a compressed air mechanism that permits the head to speak in whispers.
You can read the rest of this review at Google Books.