It does go on head to head record first, comparing the two games the clubs played against each other on aggregate, sort of. Olympiakos beat Arsenal 3-2 in their other game, therefore Arsenal need to beat them by two or more goals to have a better head to head record. Or, Arsenal could win by the same result (3-2), and it would go down to goal difference, and Arsenal would go through. I believe.
So Arsenal need any two goal winning margin or above, or to win by 1 goal when scoring at least 3. Anything else and they are out. What's the scenario in Chelsea's group? It looks complicated if they draw with Porto, and Dinamo Kiev win as they no doubt will. They all finish on 11 points but who goes through?
Taken from BBC Sport: "Chelsea's fate in Group G is clear - they need a point from their meeting with Porto at Stamford Bridge to secure a place in the last 16. The winner of that match will top the group. Dynamo Kiev - who face whipping boys Maccabi Tel Aviv - will be sure of a place in the last 16 with a win thanks to a superior head-to-head record against Porto. If Kiev win and Chelsea and Porto draw, all three teams will finish on 11 points. Their fate would then be decided by their three-way head-to-head record - with their group results against each other converted into a mini-league - and it would be Porto who finish third and head into the Europa League."