It depends on what you mean by "obsolete"! Heavy infantry types are not like iPhones, where each model is eventually superseded by an objectively superior one. At his most essential, a hoplite is a spearman with a large shield, and this concept wasn't truly obsolete until the rise of effective gunpowder infantry. Pop histories of Antiquity will tell you that the hoplite was outclassed by the phalangite, and the phalangite by the legionary - but that "tech tree" way of looking at military history can't explain why, just a few hundred years later, Roman infantrymen suddenly seem to look an awful lot like hoplites. Clearly there are factors involved beyond simple technological or tactical improvement over time.
It doesn't help that we don't really know when hoplites stop being around. After Alexander, our sources for political and military narrative shift away from the Greek states to the Hellenistic kingdoms, and we hear much less about the fates and fighting styles of small communities from that point on. We can rarely sketch a thorough picture of the way they responded to their new geopolitical reality, in which kings with huge territories and vast resources were able to field enormous armies of professional soldiers. Even when older Greek states get swept up in the power struggle, we almost never get any detail about the kind of troops they used. We know that these states typically didn't have the means to pay for the upkeep of a Macedonian-style pike phalanx and large units of heavy cavalry. But did they even try to change their fighting style to meet the challenge? Or did they simply stick with their citizen levy of hoplites and cavalry, trusting that the old formula would win out in the end? We know that even the Hellenistic kingdoms frequently used city-state levies to round out their armies, and actively sought the support of these states. Would the troops they sent have been hoplites? When did the last hoplite pick up his double-grip shield to go into battle?
The fact that we know so little for certain has made it easy for people to claim that hoplites had gone away. There's little evidence of them after the rise of Macedon, and the easiest explanation is that the Macedonian pike phalanx proved so tactically superior that they instantly removed the hoplite from all Mediterranean battlefields. But this is clearly too simple. First, there weren't so many states that could afford a pike phalanx; these states weren't able to touch, let alone subjugate, all the states that had ever fielded hoplites. Second, as I said, no Hellenistic army ever consisted of just pikemen and heavy cavalry, and there would have been a place for versatile and aggressive hoplites to round out their infantry component. Third, in his 'The fighting poleis of the Hellenistic period', John Ma has shown that even in a world of huge Hellenistic kingdoms, smaller Greek states continued to wage wars amongst themselves, likely without interference from anyone who could bring a pike phalanx to bear on them. Fourth, the Greeks' early encounters with pike phalanxes suggested that they were not indestructible, and that well-led and eager hoplites could hold their own against them, as at Issos in 333 BC or Krannon in 322 BC; the arrival of the phalangite did not mean the hoplite was instantly obsolete and useless. The fact that most Greek states couldn't afford their own pike phalanx didn't mean that they were no longer able to play any role in warfare, and the most obvious way for them to participate in conflicts was with their existing hoplite militias.
So what do we know? One thing is certain: defeat at the hands of the Macedonians didn't immediately cause the Greeks to abandon hoplite gear. Indeed, our evidence for Athens suggests that they were more interested in emulating the professionalism of Philip's army than its equipment. After their defeat at Chaironeia, the Athenians took the unprecedented step of introducing a mandatory 2-year period of military training for all male citizens who turned 18. But at the end of this training period, the state offered the recruits a spear and hoplite shield. Apparently they didn't think their equipment or tactics were at fault; the problem was simply that they didn't have the discipline and training that made Philip's infantry so effective. Indeed, Demosthenes' speeches urging the Athenians to resist Philip all focused on the readiness and training of his army, not on its weapons and tactics. By the time of the Galatian invasion of 279 BC, the Athenian hoplite levy could apparently be characterised as a well-disciplined force.
It's not until much later that we find Greek states actually adapting their fighting style to new military realities. Nearly a century after the death of Alexander, two of the last kings of Sparta embarked on a total overhaul of their state organisation, in the process reforming their old hoplite levy into a pike phalanx to compete in a larger geopolitical sphere. By that time a few other Greek coalitions had already pooled their resources to create such a force, but we don't hear the specifics of how they did it. At the same time, literary sources and images suggest an increasing shift from heavily armoured hoplites to lighter, more versatile thureophoroi (carriers of the thureos, a smaller single-grip shield that may have been borrowed from the Galatians). These troops were better suited to form the middle ground between the heavy phalangite and the light-armed troops that supported it. We don't quite know where these troops first appear, or whether they really replaced hoplite levies, but we do know that they were welcomed in Hellenistic royal armies along with peltasts and other "medium" infantry. In this sense, the recruitment market may have helped to push hoplites to the margins, making them into the defining infantry of regional, amateur armies.
In short, the best we can say is that hoplites faded slowly, and only on the grandest scale of military operations, where they were no longer tactically necessary. On the smaller, local level, hoplites probably remained the mainstay of citizen levies for a long time - possibly even until the subjection of the Mediterranean by Rome, when general peace meant that local states no longer required an active militia. We don't have the details of this story of decline, since our sources don't care to tell us. Either way, there is never a question of hoplites becoming obsolete. As a troop type, they remained basically effective as long as they could adapt to the increasing professionalism of Mediterranean warfare. Even the Romans eventually realised the value of a sturdy line of heavily armoured spearmen, and so hoplite-like forces eventually returned to the field.