Does J.K. Rowling address how the interactive portraits work? Would a portrait painted after a Wizard/Witch died become interactive, or does the painting of the portrait have to take place during the Wizard/Witches lifetime?
There is no information about needing to be alive/dead as far as painting time, BUT the talking/interactivity part must be once the wizard is dead.
The critical need is for the portrait to be present where the wizard spend a lot of time and left an "imprint". In the words of my real estate agent, "location, location, location".
In other words, it's not the portrait doing the talking, it's the portrait serving as a conduit for the remains of the wizard's imprint... a portraity Ouija board if you will.
From J K Rowling at the Edinburgh Book Festival, Sunday, August 15, 2004
Q: All the paintings we have seen at Hogwarts are of dead people. They seem to be living through their portraits. How is this so? If there was a painting of Harry’s parents, would he be able to obtain advice from them?
JKR: ... They are all of dead people; they are not as fully realised as ghosts, as you have probably noticed. The place where you see them really talk is in Dumbledore’s office, primarily; the idea is that the previous headmasters and headmistresses leave behind a faint imprint of themselves. They leave their aura, almost, in the office and they can give some counsel to the present occupant, but it is not like being a ghost. They repeat catchphrases, almost. The portrait of Sirius’ mother is not a very 3D personality; she is not very fully realised. She repeats catchphrases that she had when she was alive. If Harry had a portrait of his parents it would not help him a great deal. ...
Here is updated info about Potraits from pottermore
Hogwarts portraits are able to talk and move around from picture to picture. They behave like their subjects. However, the degree to which they can interact with the people looking at them depends not on the skill of the painter, but on the power of the witch or wizard painted.
When a magical portrait is taken, the witch or wizard artist will naturally use enchantments to ensure that the painting will be able to move in the usual way. The portrait will be able to use some of the subject’s favourite phrases and imitate their general demeanour. Thus, Sir Cadogan’s portrait is forever challenging people to a fight, falling off its horse and behaving in a fairly unbalanced way, which is how the subject appeared to the poor wizard who had to paint him, while the portrait of the Fat Lady continues to indulge her love of good food, drink and tip-top security long after her living model passed away.
However, neither of these portraits would be capable of having a particularly in-depth discussion about more complex aspects of their lives: they are literally and metaphorically two-dimensional. They are only representations of the living subjects as seen by the artist.
Some magical portraits are capable of considerably more interaction with the living world. Traditionally, a headmaster or headmistress is painted before their death. Once the portrait is completed, the headmaster or headmistress in question keeps it under lock and key, regularly visiting it in its cupboard (if so desired) to teach it to act and behave exactly like themselves, and imparting all kinds of useful memories and pieces of knowledge that may then be shared through the centuries with their successors in office.
The depth of knowledge and insight contained in some of the headmasters’ and headmistresses’ portraits is unknown to any but the incumbents of the office and the few students who have realised, over the centuries, that the portraits’ apparent sleepiness when visitors arrive in the office is not necessarily genuine.
Well, it's not the most reliable source (being second hand, and possibly someone messing with him), but in CoS, Colin Creevey says:
“and a boy in my dormitory said if I develop the film in the right potion, the pictures’ll move.”
which suggests, at least for photos, that it's a matter of post-processing, rather than something specific about the subject.
I have no canon evidence, but I'd take a guess that a specific potion being used in the paint allows for the effect you commonly see with paintings. It's possible a spell could be cast after creating one, but something used as part of the creative process seems more consistent with JKR's style.