Thank you for your question about your wormy raspberries. They most likely have been infested by the spotted wing drosophila insect, aka 'vinegar fly.' As you'll learn from this article, it really takes some effort to identify, monitor and control them if you want to keep them from ruining your berries.
The simplest way to prevent infestation is to cover your berry canes with netting, but, as you can read on page 8 (under 'physical control'), doing that too early prevents pollination; doing it too late traps the females with your growing fruit. This is why monitoring is so important: you need to keep ahead of them!
Hope this is helpful. Good luck!