When does the word solo have an accent (tilde) on the first o (sólo)? When does it not?
You should never put an accent in "solo" if you want to follow RAE latest recommendations.
Following accentuation rules "solo" would never have an accent but the previous rules recommend it in cases ambiguity between the adverb and adjective meanings.
According to the RAE (which haven't updated the DPD yet) the ambiguity cases are very rare and can be solved using other words (solamente, únicamente...)
Solo has an accent when it means "only" and can be mistaken with "alone":
Compare these two sentences:
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).