I disagree with the other answers. There is a decidedly military connotation to "jawohl". As a pacifist I have never in my life used this word, exept in an ironic sense when someone used a tone of ordering me, to show him that he had overstepped my limits of polite conversation. In my social circles, using the word would result in a frown, or a quip asking you to relax.
That said, for a militarily-minded person, or someone appreciating hierachies, it might be just normal to exchange "ja" for "jawohl". Under military discipline addressing a superior would always afford naming his rank, as in "jawohl, Herr Hauptmann". Leaving out the rank would be a logical consequence if you don't know whether the person you are talking to is your superior, or a specific rank does not apply, for example a clerk in a shop adressing a customer.
If someone puts this in the mouth of a Stasi officer in a film script, it is to characterize him as someone from a "Prussian" culture of discipline ("Preußische Disziplin" is a fixed term for unwavering dedication to your duties), and unable to communicate with other people on a basis of equality.
There is a nuance in pronounciation that also can convey a meaning. If you shout "Jawohl!" loudly in a parade ground voice, the pronounciation unavoidably will shorten the long -ohl to a short one: "Jawoll!". If you use the short -oll in a situation where it is not necessary, it can be a light, toungue-in-cheek mockery.
The most famous use in this sense might be the hit song by Hans Albers and Heinz Rühmann Jahohl, meine Herr'n, the title song for the 1937 film comedy The Man Who Was Sherlock Holmes. The two comedians play a pair of private detectives who impersonate Sherlock Holmes and Dr. Watson to gain more business.
While the record label did use the correct spelling "jawohl", what they are singing is definitely "jawoll" (tellingly the English WP article also uses this spelling):
Jawoll, meine Herrn, die Sorgen sind fern,
wir tun was uns gefällt.
Und wer uns stört,
ist eh er's noch begreift,
längst von uns schon eingeseift.
Jawoll, meine Herrn,
darauf können Sie schwörn,
jawoll,
jawoll,
jawoll.