⟩ Suppose I don't get the position, is it OK to ask for feedback?
Yes. In fact, I highly encourage you to take this action, for a number of reasons. First of all, you do want to know why you didn't get the job, and often the decision-maker will give you truthful insight. This is especially likely if you networked with her or him before you applied, or when you interviewed for the position you had especially good rapport). The reason you were not selected might have nothing to do with you (perhaps they had to hire someone else for timing or because they are the boss's brother-in-law). Or it might be that another candidate had a superior set of skills and experience. Alternatively, if it was a reason relating to your interview performance, you want to know this so you can remedy it for the future.
Your request for feedback also shows the interviewer that you are interested in their opinion, and, by extension, that you are still committed to the company. So in the course of asking for feedback, be gracious, thank them for their candor, and clearly indicate that you are still interested in working for this organization and hope to help them in a future capacity.
Finally, people respond positively to those who show they want to improve. After all, successful workers seek opportunities to develop skills and improve the circumstances and skills of their team. By sharing your desire to learn how you might have erred in the interview, you demonstrate this important attribute and you keep the door open for you to come back, perhaps for a different job, or perhaps for the same job should the successful candidate not work out.