Ok well lets write down the basics first:
Speed= Distance/time
Distance = d
Time to work=T1
Time back = T2
so you can write two equations form this data to work out the two individual speeds (to work and back)
8= d/T1 and 4= d/T2
Now Average speed = total distance/total time
so a rearrangement of the top equations gives:
Average speed = [2d] / [ (d/8) + (d/4)]
The "d"s cancel out leaving you with (16/3) or 5.3ms-1