That's right -- usually the heroes find out the villains' identities pretty quickly, because usually the heroes catch the villains and put them in jail. They can't be put on trial without their names being known.
In the comics it was a couple of decades before Catwoman's identity of Selina Kyle was discovered, but that's because she herself had suffered from amnesia for many years and didn't remember who she was before.
But generally, aside from the Joker, long-running villains whose identities go unrevealed for a long time are more a Marvel thing than a DC thing. In Spider-Man, the Green Goblin's identity was a secret for a while, and I think the second Green Goblin's was too. Hobgoblin's identity was such a secret that even the comic's editors didn't know it; after the character's creator left, the Hobgoblin was given a different secret identity than he'd intended, and it wasn't until quite a few years later that he came back and revealed that had been a fakeout and Hobby was really who he'd wanted him to be all along.
In the comics it was a couple of decades before Catwoman's identity of Selina Kyle was discovered, but that's because she herself had suffered from amnesia for many years and didn't remember who she was before.
But generally, aside from the Joker, long-running villains whose identities go unrevealed for a long time are more a Marvel thing than a DC thing. In Spider-Man, the Green Goblin's identity was a secret for a while, and I think the second Green Goblin's was too. Hobgoblin's identity was such a secret that even the comic's editors didn't know it; after the character's creator left, the Hobgoblin was given a different secret identity than he'd intended, and it wasn't until quite a few years later that he came back and revealed that had been a fakeout and Hobby was really who he'd wanted him to be all along.