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.\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.sloppyparmade 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.\hfilor\hfillas the interfigure separator, as they are, by design, stretchable.