VEEEEEEERY nice web application by Josh Turner. I'm pretty sure jailbreakers out there would definitely want to know what iOS your device will be shipped with if you had the opportunity to be able to check. I'm not sure how many retailers or branches would actually let you take a look at the serial numbers, but if you COULD, here's something to check it with.
Note: I take ZERO credit for this, it's all Joshua Turner and his development and algorithm breakdown, just sharing it.
Link to the Web App
So pretty much, this web application has a very simple UI.
Enter the serial number of the device that you're trying to check up on, and it'll respond with this, the iOS that it came with.
So I've inputted a sample with my iPhone 4S, and it comes back with iOS 5.1.1, which was indeed the iOS that my 4S came with.
AFAIK, the results are accurate. I've tested this on 60 devices and it showed up with the original iOS installed when shipped. Note that this will be inaccurate if your device is a replacement, refurbished, or possibly used/2nd hand device as they're restored before they're sold, so they'll give you the iOS, but it won't be the one that's on the device since it's been restored before, and unfortunately, there's no way in checking that unless you get a hold of the actual shipment date and compare it to the iOS signature dates.