Does every morphism BG-->BH come from a homomorphism G-->H? Given a homomorphism f:G→H between smooth algebraic groups, we get an induced homomorphism of algebraic stacks Bf:BG→BH, given by sending a G-torsor P over a scheme X to the H-torsor PxGH, whose (scheme-theoric) points are {(p,h)|p∈P,h∈H}/∼, where (pg,h)∼(p,f(g)h).
Is every morphism of algebraic stacks BG→BH of the form Bf? If not, what is an example of a morphism not of this form?
 A: Depends on the base scheme and the topology being used. For example if you're working over a field k in the etale or the flat topology, and take the group G to be trivial, you're asking if H^1(k,H) is trivial, which is obviously false in general. This is, in a sense, the only obstruction: for any base scheme S, giving a map from BG to any stack Y (in stacks/S) is the same as specifying a point y of Y(S), and a homomorphism G -> Aut_S(y). In particular, if BH(S) is connected (i.e., if H^1(S,H) = *) then the answer to your question is positive.
A: There is some result in the case of Lie groupoids and I believe this is related.
Given Lie groupoids $\mathcal{G},\mathcal{H}$ a morphism of stacks $B\mathcal{G}\rightarrow B\mathcal{H}$ comes from what is called a $\mathcal{G}-\mathcal{H}$ bibundle $P$. This bibundle comes from a morphism of Lie groupoids $\mathcal{G}\rightarrow\mathcal{H}$ if and only if the anchor map $a:P\rightarrow \mathcal{G}_0$ has a global section.
This can be found in proposition $3.36$ of Orbifold as stacks. I think similar result in case of Algebraic geometry can be said.
A: As a complement to the answers above : it is kind of well-known (at least I thought it was) that the natural morphism 
$$\operatorname{\mathbf{Hom}}_{gr} (G,H) \to \operatorname{\mathbf{Hom}}(BG,BH)$$
is an $H$-torsor (where $H$ operates on $\operatorname{\mathbf{Hom}}_{gr} (G,H)$ by conjugacy). In other words, the internal Hom stack $\operatorname{\mathbf{Hom}}(BG,BH)$ identifies with the quotient stack
$$\left[\operatorname{\mathbf{Hom}}_{gr} (G,H) \right/H ] \simeq \operatorname{\mathbf{Hom}}(BG,BH)$$
of the Hom sheaf $\operatorname{\mathbf{Hom}}_{gr} (G,H)$ by the conjugacy action of $H$.
This of course answers the original question completely (globally, no; locally, yes).
The proof is straightforward enough. For instance here is a sketch of the local surjectivity: let $\alpha : BG\to BH$. If $s_G$ is the canonical section of $BG$, we get a morphism  $G=\operatorname{\mathbf{Aut}}(s_G)\to \operatorname{\mathbf{Aut}}(\alpha(s_G))$. Since $\alpha(s_G)$ is isomorphic to $s_H$ locally, this defines locally a morphism $G\to H$, up to conjugacy by $H=\operatorname{\mathbf{Aut}}(s_H)$ of course.
I have learnt this from Angelo Vistoli, and since this is nice and quite useful, I am happy to share it back with you. For the context: this isomorphism is a frequent guest in non-abelian cohomology, and in tannaka duality.
A: Bhargav said this first in different words, but (by analogy with the homotopy picture) you need your map to be basepoint-preserving.  In particular, the point corresponding to the trivial G-torsor should be taken under composition to the point corresponding to the trivial H-torsor.  Once that is satisfied, then the homomorphism G -> AutS(basepoint of BH) is the homomorphism to H.
A: Taking Bhargav's answer to its logical conclusion, we get the following result.

If G, H, and K are smooth groups over
  a base scheme S, then isomorphism
  classes of morphisms BG→BH are
  given by 

Hom(BG,BH) = H1(S,H) × Homgp(G,H)

with composition Hom(BH,BK) ×
  Hom(BG,BH) → Hom(BG,BH) given by

(Q,h) o (P,f) = (Q + h∗P, h o f).


To see this, note that a morphism from BG to any stack X consists of a point P ∈ X(S) and a group homomorphism G→AutX(P). In the case of X=BH, this amounts to a choice of H-torsor P over S (i.e. an element of H1(S,H)), which is where you send the trivial G-torsor over S, and a group homomorphism f:G→AutX(P)=H.
A: I am not an expert on this topic, so someone please correct me if I'm wrong, but I believe the answer to this question is yes.
The stack BG (resp. BH) is represented by the simplicial scheme also usually denoted BG (resp. BH) which is obtained by covering BG (resp. BH) by a point and then taking the nerve of this covering.  Then a map from BG \to BH should just be given by a map of the corresponding simplicial schemes, which in particular includes a map G \to H (these are the 1-simplices). However, I think that this map completely determines the map BG \to BH (this should have something to do with the fact that BG and BH have no nontrivial homotopy groups beyond \pi_1, so we really only need to work with groupoids).
