If you've never ran before in a race then you should train for 8 weeks minimum before running in a 5 K race.
To prepare before the race you should run 3 times each week for those 8 weeks to get prepared for the 5 K race to prevent any injuries when the race does begin.