Where It All Goes Down
A drab flat in a gray city on Christmas Eve
The narrator calls our attention almost immediately to the two most important details of the story's setting: it takes place on a Christmas Eve, and its two main characters live in a very unassuming flat. The action of the story depends on the fact that Christmas is sufficiently close that Della needs to buy a present now, even with her small amount of money. The couple's very humble abode brings out their poverty vividly. It's their poverty which both forces them to make the sacrifices they do, and which makes those sacrifices meaningful. O. Henry sketches the flat with just enough detail to convey an image of its squalor: it's cheap, sparsely furnished, and has a broken mailbox and a broken doorbell.
The drabness of the physical setting in which Jim and Della live creates a contrast with the warmth and richness of their love for each other. The fact that everything outside the flat is "grey" – Della watches a "gray cat walking a gray fence in a gray backyard" (6) – develops the contrast even further. Inside, we get the sense, Jim and Della's affection creates a welcoming love nest, in spite of the flat's humble nature. Outside, it's a cold, gray world, and one that is about as uncaring as Madame Sofronie.
As for the larger "where and when," we don't have much in the way of specifics. It is possible the story is set in a city – "flats" are the kind of thing you often associate with cities – but not necessarily so (the flat has a backyard, which is a little less urban). From the "gas" which Della lights (20) and the gadgets she has (i.e., a stove and curling irons), it is a safe bet that the story is set just about the time O. Henry wrote it (first decade of the 20th century), or slightly earlier.