The various comments to your question have indicated two things:
1) everyone recommends against large images as inline characters
2) you (for whatever reason) wish to have your large image set as in inline character, and not, for example, as a separate figure.
Given that, let me review the comment highlights.
1) The tikzpicture being in an hbox and not a vbox, will be treated as an inline character if it is not set apart in its own environment or group.
2) The way LaTeX works, it sets a whole paragraph at a time, trying to satisfy a set of weighted constraints (the weights being set by "penalties" and \sloppy just defining different weight values).
3) If you were using raggedright justification, the constraints are fewer and LaTeX would provide the line break to prevent margin overrun. However, with full alignment, LaTeX may be unable, using the default penalties, to arrive at a satisfactory solution. In those cases it produces an "overfull hbox" which in this case manifests as margin overrun.
4) You discovered that \sloppy "fixes" the problem, but you are worried that you don't want to prepare a whole document as sloppy.
So my first fix was to use the sloppypar environment to only fix the offending paragraph (paragraph 1 in the MWE).
You then asked if one could effectively provide a sloppypar like solution over a partial paragraph. I would say you are going from bad to worse, but I seemed to recall this solution, Cutting corners - how to delete 1 pt (0.3515 mm) or so, for squeezing things onto one row. Here I use it to stretch things across a partial row, in paragraph 2 of the MWE. It is worse than sloppypar because the word spacing changes mid line (yech!), but at least the line with the bbb characters is not "sloppy" (as you requested).
Paragraph 3 of the MWE was your own example, to prove that sloppypar does not extend over the remainder of the document.
\documentclass[]{article}
\usepackage[]{pgfplots}
\def\squeeze#1{\squeezeit#1 \relax\relax}
% REVISED SOLUTION
\def\squeezeit#1 #2\relax{#1\if\relax#2\else
\findlast#1\relax\relax%
\if.\LastChar\hfil\else
\if,\LastChar\hfil\else
\hfil\hfil%
\fi
\fi
\squeezeit#2\relax\fi%
}
\def\findlast#1#2\relax{\def\LastChar{#1}\if\relax#2\else\findlast#2\relax\fi}
\textheight 9in
\begin{document}
\begin{sloppypar}
aaaaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaa aaaaaaaa %
\begin{tikzpicture}
\begin{axis}
\end{axis}
\end{tikzpicture}
bbbbbbbbbb bbbbbbbbbbbb bbbbbbbbbb
\end{sloppypar}
\squeeze{aaaaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaa} aaaaaaaa %
\begin{tikzpicture}
\begin{axis}
\end{axis}
\end{tikzpicture}
bbbbbbbbbb bbbbbbbbbbbb bbbbbbbbbb
aaaaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaa aaaaaaaa %
\begin{tikzpicture}
\begin{axis}
\end{axis}
\end{tikzpicture}
bbbbbbbbbb bbbbbbbbbbbb bbbbbbbbbb
\end{document}

tikzpictureis a "word" (it is in an hbox, not a vbox) or at least it can be used as such (that's a feature, not a bug). If you want it to not act as a word, you have to set it as such, either in its own paragraph or centering environment, or something. – Steven B. Segletes Jun 05 '14 at 17:23\makebox, etc. If you were in\raggedrightmode, the line break would have happened. But in full justify mode, LaTeX just couldn't make it work. – Steven B. Segletes Jun 05 '14 at 17:29aaaaa{\centering\begin{tikzpicture}...\end{tikzpicture}\par} bbbb, you may get something preferable. There are many such ways... – Steven B. Segletes Jun 05 '14 at 17:35centeringdoesn't work. But...\sloppy \begin{tikzpicture}...works. The problem is that I am not sure ifsloppywill be kept activated for the rest of the document and that apparently is a bad practice since high quality justification will be lost for normal cases. – alfC Jun 05 '14 at 17:40\begin{sloppypar}...\end{sloppypar}– Steven B. Segletes Jun 05 '14 at 17:45\[ ... \]. – barbara beeton Jun 05 '14 at 17:53sloppyparmade the trick. That presumably must enclose the whole paragraph. I wonder if there is a more "local" option that I can just put next to the offending picture. BTW, I realize that this has more to do with the size of the word/picture than with the fact that it is a picture. (for example a\begin{axis}[tiny]will not produce bad behavior at all). Obviously the problem is that the justify algorithm doesn't expect very long words. – alfC Jun 05 '14 at 18:07sloppyparis probably the approach most likely to work, albeit the result will probably not look very good. a small picture, such as a logo, in scale with an ordinary word, is often inserted either as in-line code (as you have here) or with\includegraphicsand behaves very nicely. a wide element (for example an unbreakable url as well as a picture) will stress the line-breaking algorithm. – barbara beeton Jun 05 '14 at 18:13\sloppyjust defining different weight values). Because of this fundamental process, you can not set part of a paragraph as sloppy. I did have a related answer that might emulate a partial sloppy. If I find it, I'll provide the pointer. – Steven B. Segletes Jun 05 '14 at 18:13\\from the rest. (It also worked with\phantom{,}which I found in desperation.) – alfC May 10 '16 at 05:53\hfilor\hfillas the interfigure separator, as they are, by design, stretchable. – Steven B. Segletes May 10 '16 at 09:54