I have read posts where persons detected beaches in Cuba, with no issues or problems.
As for "hearing that it's illegal" there, you'd have to ask yourself "says who?", or "where did your source get that info?". Humorously, whenever you read something like that, it's often time someone just quoting something they read from some other earlier post. And when you go to THAT post, it too is getting it's info from something "someone heard" blah blah blah. And ultimately, even if you DID find some official source (a link to something saying "no"), even THEN it's often couched in things like antiquities, or exporting gold bars, or shipwreck salvor things, blah blah blah. So you've got to figure it's more than likely some answer given way-back-when, to someone asking some border consulate lawyer there "can I bring my metal detector?".
Such was the case, for example, of someone who asked a Mexican official. They were told "no". So the person posted that info. But multiple others objected and said "since when?" and "we go there all the time with no problems". And there's dealers there (presumably selling them for lawful usage).