How do you play Scrapheap Scrounger's ability?
Scrapheap Scrounger's activated ability works if and only if it's in the graveyard. That is implicit for all such abilities, when they wouldnt make sense otherwise.
Generally, you are correct in that abilities on permanents only function on the battlefield. There are, however, exceptions to that. The Scrounger's ability falls under one of them:

112.6. Abilities of an instant or sorcery spell usually function only while that object is on the stack. Abilities of all other objects usually function only while that object is on the battlefield. The exceptions are as follows:
112.6k An ability whose cost or effect specifies that it moves the object it’s on out of a particular zone functions only in that zone, unless that ability’s trigger condition, or a previous part of that ability’s cost or effect, specifies that the object is put into that zone. The same is true if the effect of that ability creates a delayed triggered ability whose effect moves the object out of a particular zone.