Is it correct to say have you had a std or an STD?

They are both technically right, but the majority of people would say 'an' STD. When talking about something that begins with a vowel-sounding letter, we tend to use 'an' - it just sounds better to say "an automobile" than "a automobile" after all. That's the reason why we have that a/an difference, the way the phrase sounds.

The 'S' in STD stands for 'Sexual' and would therefore be 'a Sexual' if vocalising the unabbreviated word. But when it is abbreviated, it is pronounced 'Ess' and therefore begins with a vowel-sounding letter. It therefore sounds more natural to say 'an STD' though neither version is more grammatically correct than the other.
It is a STD.