Do I have to accept or reject the offer on the spot
Offers on the spot are quite rare. Typically you talk to a number of people and they need some time to integrate the data (means "talk about you"). They often run multiple candidates and don't make a final offer until they have interviewed them all and ranked them. Then they will offer in order of the list. It's much more likely that there is a significant time gap between the interview and an offer, decline or simply just nothing. Even if they want to hire you, there is often also a bit of back and forth on the details (timing, comp, benefits, relo, equity, contracts, ...) before the formal issue gets offered
Getting an offer on the spot is a clear indicator that you are very strong candidate, so it's a good problem to have.
is it okay to ask for some time?
Yes. One week is fairly normal and can often be extended with the right reasons (and candidate). However, it's better to analyze the situation up front and make sure that you know what your own decision criteria are. If you have done your up front research properly and nothing overly surprising happens at the interview, you should be able to make a decision quickly. Primarily you should take this time to study the details of the offer, carefully read all the contracts and agreements you are supposed and work through any adjustments and/or misalignment.
Blanket Advice: never sign anything that you haven't carefully read and that you are sure you fully understand.