How you go about it depends partly on your hopes for the outcome, partly on the practicalities of the situation, and also on the reasons for your decision. Maybe you are not really sure that you want to leave, and would like to see whether your job can be improved within the existing company. Work out in advance what your terms for staying would be and then focus on achieving these. The first person to learn of your departure, other than your loved one at home, should be your line manager. Don't let the boss learn of your impending resignation through the grapevine.
People quit jobs for all sorts of reasons, positive and negative.
Acceptable ones include improved opportunity for promotion, vastly more money elsewhere, or moving to follow your partner. Other reasons may be harder to voice, such as a breakdown in personal relations, feeling taken for granted, or when 16-hour days become the norm. So if bad feeling is a factor, you may prefer to draft a letter or email. This way you can consider your choice of wording carefully. Sleep on the draft overnight and then do a final edit to make sure you have said exactly as much or as little as you intend.