Keeping in mind the events in Libya and Syria, is there ever a time when it is okay to back an uprising by armed rebels, including by giving them weapons?
The best answer is simply, no. If one were to disagree and take the view that, as a matter of principle, rebels should be supported against repressive regimes, it will require untenable and foolish strategies all over the world. Moreover, it will often fail, like it did in Syria even after so many years.
Legitimacy
Where it may be wise to support non-government armed groups is where the case can be sufficiently made that they are the legitimate authority, as in, the state or some other legal authority, and where some formal ties can be established. In such a case, one is not really supporting rebels at all but supporting governments, and simply disagreeing about those governments. The international community and the UN are often obstinately wrong in this respect, often continuing to recognise dead regimes just because they did not like how it happened.
A decent principle to follow is that of popular sovereignty, whereby the will of the people decides whether there stands one state or another state. Referendums are excellent means to establish the validity of such sovereignty.
Different regions of the world have somewhat differing models of authority and, as such, the groups one supports in the course of supporting legitimate authorities may look "rebel"-like to outside observers. However, a group that advertises itself as a rebellion but has no clear idea about governing and can give no guarantees is usually not worth establishing relations with.
Honourable rebellion
The best rule would be that one's country may support non-state elements in a country where these elements conduct themselves in an honourable and state-like way, and where a referendum or other democratic exercise has actually established popular sovereignty. This is in stark contrast to simply producing "error"-ridden media reports asserting that the people want some kind of uprising, as is so typical of the Western press when reporting on countries like Cuba, Venezuela and Syria, only to later be corrected or redacted after the damage is done.
Another good rule is to be a sincere contributor to local and regional security in a conflict zone based on clear treaties from day one, rather than suddenly barging in on moral pretexts, as was the case with many interventions. It should always be a local power that takes the lead on how to intervene in a conflict, not a foreign superpower. Any foreign power that interferes against the wishes of the region is insincere, and little better than an invader.
Although intervention and support of rebels has often been done in a reckless and self-serving way, the practice should not be ruled out in its entirety. Where it is aligned with popular sovereignty and the will of nations to independence, it is justifiable. Support for the changing of national borders should not be ruled out, either, but only at the initiative of the local people and as a means of remedying past colonial errors.