1930: The exact phrase "artificial gravity".
The OED's earliest citation for the phrase artificial gravity is from Olaf Stapledon's 1930 novel Last and First Men: A Story of the Near and Far Future, which is available at Project Gutenberg Australia. From Chapter XII, section 3:
It did not take the Fifth Men many centuries to devise a tolerable means of voyaging in interplanetary space. Immense rockets were constructed, the motive power of which was derived from the annihilation of matter. The vehicle was propelled simply by the terrific pressure of radiation thus produced. "Fuel" for a voyage of many months, or even years, could, of course, easily be carried, since the annihilation of a minute amount of matter produced a vast wealth of energy. Moreover, when once the vessel had emerged from the earth's atmosphere, and had attained full speed, she would, of course, maintain it without the use of power from the rocket apparatus. The task of rendering the "ether ship" properly manageable and decently habitable proved difficult, but not insurmountable. The first vessel to take the ether was a cigar-shaped hull some three thousand feet long, and built of metals whose artificial atoms were incomparably more rigid than anything hitherto known. Batteries of "rocket" apparatus at various points on the hull enabled the ship not only to travel forward, but to reverse, turn in any direction, or side-step. Windows of an artificial transparent element, scarcely less strong than the metal of the hull, enabled the voyagers to look around them. Within there was ample accommodation for a hundred persons and their provisions for three years. Air for the same period was manufactured in transit from protons and electrons stored under pressure comparable to that in the interior of a star. Heat was, of course, provided by the annihilation of matter. Powerful refrigeration would permit the vessel to approach the sun almost to the orbit of Mercury. An "artificial gravity" system, based on the properties of the electro-magnetic field, could be turned on and regulated at will, so as to maintain a more or less normal environment for the human organism.
1895: The idea of using centrifugal force to generate artificial gravity in a space vehicle or habitat.
This is in Konstantin Tsiolkovsky's 1895 work Грёзы о Земле и небе (Dreams of Earth and Sky). From Everett F. Bleiler's review in Science-Fiction: The Early Years:
Essentially a long (100-page) essay on topics in astronautics and related fields, but with two extended fictional sections. [. . .] The second section, which is longer, is concerned with superscientific responses to the special physical conditions of a planetoid in the asteroid belt. The plant-like natives, who are humanoid in form, but have small wing-like appendages, obtain energy from chlorophyll and solar radiation. They are far ahead of us in science and perform amazing feats of planetary engineering, like dismantling asteroids into rings or "necklace" formations so that they can take advantage of very low gravity. For space travel between the larger bodies they have systems of step-speed trains that easily attain escape velocity, permitting even interstellar travel. Their dwellings are like small greenhouses; they obtain power from solar cells; and they create gravity by centrifugal force.
Tsiolkovsky mentioned artificial gravity again in his 1920 novel Вне Земли (Out of the Earth). From Bleiler's review:
A short novel describing the first venture into space. Containing long expositional passages, it is the first important hard interplanetary novel since Jules Verne's lunar voyage. [. . . .]lThe vessel functions perfectly, and the explorers put themselves into a hundred-minute orbit around the earth. The author describes the nature and function of space suits, the problems of weightlessness, and artificial gravity as obtained by rotating the ship. Once out in space for a considerable time, the men assemble a gigantic space greenhouse; it is about sixteen hundred feet long, seven feet wide, glazed, provided with suitable atmosphere, and fertilized with the excrements of the explorers.