'Who likes the boy?' asks for people who like the boy.
'Whom does the boy like?' asks for people who are liked by the boy
In Polish it's easy to distinguish, because the subject appears in the nominative case and the object in the accusative case. Hence you have:
'Kogo lubi chłopiec' - 'chłopiec' is the subject, 'kogo' is a question about the object, so it should be 'Whom does the boy like?'
'Kto lubi chłopca?' - 'Kto' is a question about the subject, 'chłopca' is the object, so it would translate to 'Who likes the boy?'
Who likes the boy => Kto lubi chłopca - in this case 'affection' comes from some person (who) to the boy. The answer is: (A) lubi chłopca. - (A) -noun in Nominative.
In the sentence above 'affection' comes from the boy and the subject of this 'affection' is someone (whom). The answer is Chłopiec lubi (A) - noun in Accusative.
As you can see the pattern is : (Nominative) lubi (Accusative). And it is kept in all the sentences above, questions and aswers.