Disclaimer: I was not published during my undergrad. Nor did I even consider it at the time. But I wish I had. I'm going to address this in the context of the experimental sciences, but some aspects may carry over to other areas.

OK, so getting published as an undergraduate is going to be difficult. PhD students and postdocs regularly get rejections for their work from journals. But it is possible, though the submission and publication may not happen until after you have left university.

Step 1: Pick a field and pick a supervisor.
I'm assuming you're already at university, and that you are therefore largely limited to the staff working at the institution. As early as possible (no, seriously, the first month of your first year is not too early!) you need to pick a topic and a staff member to supervise you. There are a lot of factors here: you may be lucky enough to work with a world expert in something you've been fascinated in since your childhood. But chances are that you'll have to make some choices between less obvious options, and there may be a tradeoff between the topic you're most interested in, and the support you can recieve. I would suggest a senior professor with a very active (and well-established) laboratory, and lots of staff. While senior professors are very busy, they can delegate work to their junior staff or PhD students. If you approach newly appointed teaching staff they often won't have enough time to work with you as effectively, and they may be less likely to have staff resources to spare.

Step 2: Pick the type of publication you are seeking.
A review or a research article? In either case I'd recommend that your dissertation or thesis is on the same topic. Keep in mind that in order to succeed here you'll need to massively increase your knowledge and/or laboratory skills. There's a reason undergraduates rarely get to publish! If you're set on a review you'll need to become an expert in the field, to the point that your writing and insights are worth people with dozens of letters after their name taking the time to read. I'd suggest that a research paper is potentially easier, but only if you're willing to be part of a bigger team. So not only won't you be the only author, you'll be one of many (probably one of the names in the middle). Not only that, but you probably won't write the paper - that job will go to the PhD student or postdoc who did most of the work, with editing support from their seniors/supervisors (one of whom is also probably yours).

Step 3: Ask for a meeting.
Before you do this you need to be certain that this is the lab and the professor you want to publish with. You need to have a top-level understanding of the work that goes on in their lab*, you should read every abstract they've published in the last 10 years, and as many papers from their lab that you can get hold of from the last 5**. You also need to be able to tell them why you want to work with them, what interests you about their field, and why they should agree to let you get involved with their research (i.e. demonstrate that you're not going to be a liability). You should also be up front about wanting to have your name on a publication, or you may be forgotten about by that stage, or given something in the experimental early stages! You can either ask if you can get involved with a specific project, or you can just be open and say you're interested in their field, and want to help support the research involved in their next publication, i.e. have them work out where you'd best be useful. But make sure you get input - if you have no interest in DNA, don't let them guide you onto a project of that nature!

Step 4: Work. Hard!
If the meeting goes well they will probably put you under the auspices of a junior professor or postdoc. You'll need to learn lots of practical skills, but at the same time not detract from their own work. Be an asset, not a burden - though this will involve being a bit of a dogsbody at times. This may be a long term research relationship, in order to get the publication data you need to spend a lot of your spare time in the lab (maybe including summers!). This kind of dedication pays off though, and can lead to opportunities within the group and their wider network after your undergraduate degree. The more time you spend there, the greater your contribution to the research paper (i.e. the fewer other authors), and the greater chance of ending up on more than one publication.

Good luck!

* if you're struggling with this, try networking. I'd recommend asking one of their mid/senior PhD students to talk you through the current projects in return for a coffee or a beer. Be humble and people will help you! But don't let them sell you their project above all others, or put you off it.

** Keep in mind that at a senior level they may be an author (/supervisor) for publications where the work has been done elsewhere, either due to current collaborations, or historical ones. If in doubt, check the other names on the paper and look them up on linkedin etc. If none of them appear to have a history at your institution, they may be less relevant. Again, talking with a PhD student may help clarify this.