Within the fantasy genre, whether literature, movies, video games, etc., dwarves are predominately depicted with Scottish accents, being members of clans, and a variety of other Scottish stereotypes.
When did this depiction first occur? Is it something that began in the past few decades, or does it have a much longer history?
It's a fairly recent phenomenon, actually, and owes a great deal to roleplaying games like Dungeons & Dragons and Games Workshop's Warhammer Fantasy Battle tabletop game and associated media. The first edition of D&D was published in 1974 and WFB in 1983; both were based largely on Tolkien's The Lord of the Rings, but were scrubbed to avoid the lawyers of the Tolkien Estate (which is why they halflings instead of hobbits to this day), and continued to diverge and develop from there. One particular influence on D&D was Poul Anderson's Three Hearts and Three Lions (1961), which featured the dwarf Hugi that spoke with a distinct Scottish accent:
Hugi tugged Holger's sleeve. 'We can track him if ye wish,' he said. 'Ma nase hairs be atwitch wi' his stink.'
I think Hugi might be the first major fantasy dwarf post-Tolkien that was distinctly Scottish is speech and culture.
Real-world cultures that applied to Dwarves varied. Tolkien's original conception was actual based on Jewish peoples, as argued in The Secret Jews of the Hobbit by Meir Soloveichik:
We have, then, a bunch of short, bearded beings exiled from their homeland, who have dreamed forever of returning. They are linked to a place they lost long ago, dwell in other realms throughout the earth, and yet are so profoundly connected to their own kingdom that it remains vivid to them while for others it is a fading memory.
Early D&D and Warhammer Fantasy conceptions tended to lean more towards mythical Norse trappings, possibly in relation to dwarves as smiths in popolar depictions of Norse mythology; the AD&D 2nd ed. Monstrous Manual (1993) for example depicts one of them with a horned helmet, which was fairly common in that edition. It should be emphasized that even at that point, D&D had a number of different settings, each with their own often distinct approach to dwarves and dwarven culture - and D&D wasn't the only fantasy game with dwarves. For example, Warhammer Fantasy 2nd edition (1987) included in addition to the Tolkienesque Dwarfs both Norse Dwarfs (who were explicitly based on Scandinavian cultures), and Chaos Dwarfs (mutants) - in 4th edition (1994) the Chaos Dwarfs were reimagined with a pseudo-Sumerian culture and trappings. The main Dwarf contingent, while being strongly fantasy-influenced, began to appropriate a few more Scottish elements, particularly the Cult of the Slayer, whose members are beserkers, have orange-red hair, and are often depicted painted with blue spirals - in homage to ancient Scottish Celtic warfare, though of dubious historicity. One of the first blatantly Scottish Dwarfs in Warhammer Fantasy was the Dwarf Slayer Engineer Malakai Makkaison, who appeared in the novel Daemonslayer (1999) and whose speech was written with a distinct Glaswegian accent. You can see how there's sort of a collision of stereotypes happening around that point.
The computer game Warcraft: Orcs and Humans was released in 1994 and was heavily based on Warhammer Fantasy Battle, but did not feature any actual dwarves. Dwarves were a unit in Warcraft II: Tides of Darkness (1996), and followed pretty close to Norse cultural types in appearance, but were already using Scottishisms in their speech like "ach," and "aye, laddy" and picked up the stereotype for being great engineers fairly quickly.
The massive popularity of Warcraft really pushed the "Scottish Dwarfs" idea; and the Lord of the Rings live-action films (2001-2003) pretty much helped confirm it, though there's still a wide variety of dwarven cultures/depictions in various media.
No review (that I have seen), although all have carefully used the correct dwarfs themselves, has commented on the fact (which I only became conscious of through reviews) that I use throughout the 'incorrect' plural dwarves. I am afraid it is just a piece of private bad grammar, rather shocking in a philologist; but I shall have to go on with it. Perhaps my dwarf since he and the Gnome are only translations into approximate equivalents of creatures with different names and rather different functions in their own world - may be allowed a peculiar plural. The real 'historical' plural of dwarf (like teeth of tooth) is dwarrows, anyway: a rather nice word, but a bit too archaic. Still, I rather wish I had used the word dwarrow.
Speaking only of cinema, it's not hard to browse through some of the more notable depictions of dwarves to see what sort of accents they are given:
Snow White and the Seven Dwarfs (1937) - not Scottish; a bit hillbilly, actually.
The Hobbit (animated version 1977) - not particularly Scottish, although Thorin Oakenshield has an accent that I would characterize as a poor American attempt at a gruff British accent, so perhaps vaguely Scottish.
The animated Lord of the Rings (1978) - Gimli has a very definite Scottish accent.
I'm not aware of any fantastical dwarfish films between these. Quite a few after, of course, but the Scottish trope seemed to have legs by the 1970s at least.