Solo has an accent when it means "only" and can be mistaken with "alone":
Compare these two sentences:
- Voy a estar solo un día. = I'm going to stay alone for a day.
- Voy a estar sólo un día. = I'm going to stay just one day.
When I learnt the rule, I was told "si puede sustituirse por únicamente, lleva tilde", but the actual rule is, "si puede sustituirse por únicamente y puede confundirse con sin compañía, lleva tilde". That said, I usually put the accent whenever it means "only".
You can find the explanation by RAE in the DPD (Diccionario panhispánico de dudas).