I have had lots of questions like this so thanks so much for getting in touch.
Firstly, it's important to say that from a purely factual point of view, nothing bad can happen to you by simply talking to a boy while on your period. In fact no one even needs to know you are on your period unless you choose to share it with them.
It's important also to understand the reasons that you've been told this. So I'd encourage you to talk to whoever told you this and try and understand their point of view but also to have a chance to share your feelings to.