“I was told that it is safe to have sex if I have never had a period yet as it means that I cannot get pregnant. Is this true?”
Technically speaking, not having a menstrual cycle (period) means that you are not ovulating, which technically speaking means that you cannot conceive.
However, and this is the important factor… people have a menstrual cycle after ovulation. Therefore you can first ovulate without having yet had a period and can conceive before ever having a period.
So although if you do not menstruate, you are not ovulating therefore cannot conceive, you do not know when your first cycle / ovulation will happen, and therefore you may still get pregnant even if you have not had a period to date.
The only ways to prevent pregnancy are abstention (100% safe) or using contraceptives (up to 99.9% safe if used accurately).
On another note…. if you have not yet had a period, do you really think that you are mature enough to be having sex?