Most undead retain their memory.
It depends on the particular creature in question, but most types of undead retain at least some memory of their previous life.
Sometimes, the undead has a clear and sharp memory of who they were, like for a mummy, ghost, wight, or lich -- some forms of undeath are, for most purposes, simply life continued by other means.
In other cases, it's a vague recollection. Wraiths "might retain a few memories of their mortal life as shadowy echoes"; a flameskull "dimly recalls its former life"; and skeletons "sometimes pantomime actions from their past lives, their bones echoing the rote behaviors of their former living selves."
A few kinds of undead specifically have no memory of being alive. A zombie in particular is entirely mindless, and "retains no vestiges of its former self."
In the specific case of create undead, wights are clearly stated to retain their memories of life, though they are bound to the entity that turned them.
But it's ambiguous for some.
Some undead creatures' memories aren't clearly defined in the official write-up. Notable for create undead, the descriptions for Ghouls and Ghasts doesn't address the question of memories one way or the other. Meanwhile, the section on Vampires in the Monster Manual equivocates: "Whether or not a vampire retains any memories from its former life..." There is no explanation offered about what the options are, how common they might be, or what factors or situations can lead to either the retention of memories or the failure to do so.
In general, it's case-by-case and you'll have to look up the specific undead you're dealing with to find out whether they have a memory of life and to what degree, though the book still may not entirely answer the question.