Its differant for male and female. Both need to be Human Noble Origen, and have Rank 4 coercion.
Female is simple, Have a relationship with Alistair, kill Lohgaine, and get rid of Anora. There will be a option to Marry the King and rule by his side. (Only way to keep a relationship with Alistair on the throne). How you want to end this is your choice as you can either die killing the Archdemon, Alistair will die(He will always die if you bring him to the final fight and he loves you), or dark ritual Morrigan and both survive. Alistair dead leaves you on the throne alone, or dark ritual opens up further events in future dragon age games.
As a male, its a little trickier. You have to not kill Lohgaine, banish or kill Alister and be on good terms with Anora. Talk her into marrying you. Also she makes it abundantly clear shes not romanticaly intrested in you and that she wields all the power and your title is in name only.