1974, 1990, or 2004, depending
In each of these years, a new option was introduced to D&D that was labeled “warlock.” It wasn’t until 2004 that the warlock was its own class, but 1990 had warlock as a wizard kit (similar to 5e’s subclasses), and 1974—that is, the original books for D&D—had warlock as a title held by magic-users of a particular level.
1974—Original D&D, first use of “warlock” for anything
Men & Magic, the original 1974 “player’s handbook” for the original version of Dungeons & Dragons, included “level titles.” That is, your title changed depending on what level you were in a class, so as a magic-user leveled up, rather than being a 1st-level magic-user, 2nd-level magic-user, and so on, they were a “medium” at 1st level, a “seer” at 2nd level, and so on, until finally at 11th level they became a “wizard” (after that the number would be used, so “12th-level wizard,” “13th-level wizard,” etc.).
Under this sytem, “warlock” was the 8th-level title for the magic-user class. So a “warlock” was just someone who had the magic-user class, and also was 8th level.
Basic and advanced D&D also used this system, and the warlock title.
1990—Advanced D&D 2e, first use of “warlock” for a unique character choice
1990’s Complete Wizard’s Handbook introduced “witch” as a “kit” (somewhat similar to 5e’s subclasses) for the wizard class, and indicated that rare male witches “are also possible, commonly called Warlocks.” Witches get their magic from extraplanar sources (e.g. fiends), and according to the book, usually prefer “enchantment/charm” though “Conjuration/summoning and necromancy are also good choices.”
2004—D&D 3.5e, first time “warlock” is a fully-independent class
2004’s Complete Arcane for D&D 3.5e was the first time that warlock was presented as its own separate D&D class. It established many of the tropes still associated with the D&D warlock today:
Pacts—every warlock got their power from a pact forged with a powerful (but non-deific) being, but the warlock themselves didn’t necessarily need to be the one who agreed to the pact. In 3.5e, these pacts could “taint” entire bloodlines, making it possible to become a warlock because of something one’s ancestor agreed to.
Numerous places within the text refer to pacts as being made with fiendish or fey beings (which is reflected in the requirement that warlocks be Chaotic and/or Evil), but the nature of the pact doesn’t actually change anything for a 3.5e warlock (they still get “fiendish resilience” etc. even if their pact is fey in origin—the authors seemed to forget non-fiendish warlocks were possible).
Eldritch blast—every warlock was able to use eldritch blast by default, which fired a ray of arcane energy at a target, dealing damage.
Invocations—the primary magic of the warlock class was invocations, which in 3.5e meant at-will spells.
The 4th-edition Player’s Handbook presented the warlock for that edition, which was similar to the Complete Arcane version but subtly different in significant ways:
Pacts—now warlock pacts have mechanical significance, with different pacts signifying the different powerful beings capable of making warlocks. Moreover, each warlock must personally make a pact with something—no more “inheriting” the pact any more.
Spells—prior to the Essentials line, every class in 4e used the “AEDU” system, referring to At-will, Encounter, Daily, and Utility powers that were gained at fixed intervals that were the same for every class. Because warlock was an arcane class, these powers were known as spells—even the at-will and per-encounter ones. As such, “invocation” wasn’t really a term in 4e, nor was the warlock’s use of arcane magic as fundamentally different from other classes as it was in 3.5e.
And once again, with a new edition, we have a new warlock, again right there in Player’s Handbook. The 5e warlock again changed a few things up:
Pacts and patrons—in 5e, warlocks can make independent choices about the type of pact they make as well as which patron they make it with. So not only can the warlock choose to have a fiend or a fey as their patron, they can also choose to make a pact of the tome or pact of the chain with either of them (and more besides). Each choice has mechanical implications and differentiation.
Invocations and spells—in 5e, warlocks are back to having “invocations” as a unique thing that warlocks do, and these are again often at-will magic abilities as they were in 3.5e (though not always).
Warlocks also have spells, which are refreshed after a short rest instead of a long one—making them similar to 4e’s Encounter powers. And since the AEDU system is gone, and all other spells are, in 4e’s terminology, “Dailies,” warlocks once again have a unique niche of being able to use spells more frequently, somewhat reflecting their 3.5e roots.