This is pretty much answered on page 139 of the DMG, under "Cursed Items" (bold for emphasis mine):
Most methods of identifying items, including the identify spell, fail to reveal such a curse, although lore might hint at it. A curse should be a surprise to the item's user when the curse's effects are revealed.
Attunement to a cursed item can't be ended voluntarily unless the curse is broken first, such as with the remove curse spell.
So in general, no, you don't immediately know that you're cursed until "the curse's effects are revealed" or until you try to unattune from the item and can't, though it is up to the DM and how they want to play it.
If the DM decides that the curse should be a surprise, then you're not going to know about it until the effect bite you in the... well, you know.
If the DM decides that something like the identify spell will reveal a magic item's curse, then that's their prerogative.