Oedipus the King is set in that doomed city-state called Thebes. Though most Greek playwrights were Athenian, their plays are hardly ever set in their home town. In fact, they weren't allowed to do so. The tragedies did take on issues current Athenian issues, however. For example some scholars think the plague in Oedipus the King is referencing a recent plague in Athens. It seems, though, that Athenians preferred a little objective distance when examining their woes.
Athenians also liked objective distance in terms of time. Tragedies were almost always set in Greece's distant past. Sophocles and his buddies adapted their stories from their peoples' rich oral tradition. These tales of gods and heroes had been handed down for generations. Oedipus was an ancient figure even to the ancient Greeks.
Some the earliest written references to the tragic king can be found in Homer's Iliad and Odyssey. What's interesting is that in Homer's version of the tale, Oedipus continues to rule Thebes after the horrible truth is revealed. There's no blinding or exile. It's important to realize that none of the ancient stories were set in stone. Sophocles's audience expected him to mutate the myth to his own ends. They enjoyed watching the way the playwright adapted the tales in order to examine both universal truths and topical Athenian issues.
On the micro level, the play is set in front of the palace of Thebes. This was the same place from which Oedipus's father Laius once ruled. Oedipus sleeps in the same bed in which he was most likely conceived. It's more than a little ironic that Oedipus meets his downfall in the same place from which he sprung.