I've known that military aircraft with small wings can fly very fast, while commercial aircraft with big wings cannot fly as fast. Why is this?
On the whole, smaller wings produce less drag, but they also produce less lift. Less drag means the same engine can reach a faster cruise speed, but less lift limits the weight capacity and means the aircraft needs to go faster to stay airborne: the stall speed, take-off speed, and landing speed will all be faster, which in turn means longer runways are needed (or systems like catapults and landing chutes).
For a fighter aircraft, that top speed matters a lot more than the lifting capacity or take-off speed, so they're optimised with these low-drag, high-lift wings. Compare to a utility aircraft of the same size: the utility aircraft will have a less powerful engine, and wings that produce more lift at lower speeds. A utility aircraft that needed the same kind of runway as a fighter would be pretty useless.
In the other direction, compare to an airliner. These wings are tuned like a fighter's: to be maximally efficient in the cruise. But the airliner has to lift a lot more weight, so the whole aircraft is much larger, and the wings are in proportion to that. They typically also require long runways, and fly faster than a small utility aircraft. But look at the Hercules military transport. It's designed to lift a lot, but it also needs to operate from poor-condition, short runways. It has less efficient, high-lift wings, so its take-off speed is very slow for its size, and it isn't that fast in the cruise.
In summary, wings (not just wingspan, but also the shape of the wing) allow you to trade off lift and drag. High lift and drag gives you slower take-off and landing speeds, but you pay for that with a less efficient cruise. Low lift and drag gives you a faster cruise, but you pay for that with ridiculous take-off and landing speeds and the extra runway that requires.
Bottom line: It all comes down to what the aircraft is used for. Airliners simply need to maximize efficiency over speed, and jet fighters need the luxury of speed to ensure competence in combat applications.
You also asked about the relationship between speed and the wings, so let's get to that. This is a broad question, as some civilian planes have quite small wings relative to their size, and military planes with large ones, also relatively. However I will try to answer this to the best I can: There are a few major factors that affect the wing area-speed relationship, but it almost always boils down to the purpose of the plane itself (which is the determining factor usually/hopefully!). Let's start with purpose of design.
The large commercial aircraft you refer to in your question, i.e. most of Boeing and Airbus' product line tend to have larger wings simply because as they are much heavier as they get larger which requires greater lift. The usual swept wings found on these aircraft are optimized for maximum efficiency in subsonic flight. There's been a lot of study into improving this, but for now the basic narrow/wide body airliner with a cylindrical fuselage and conventional wing arrangement is the easiest to produce, and with this the swept wing design is the most efficient at the most fuel efficient speed for the design (about 0.80-0.90 Mach). It's a fact of life and physics, not much else to say unless you want to delve into the aerodynamics of it (please if you want me to say so below I'd be more than willing). In addition, these aircraft aren't required to execute fancy maneuvers, nor do they need to be resistant to battle damage or carry munitions underwing, which has allowed designers to trim the airfoils quite a bit. Sure the engines weigh quite a bit, but unlike bombs and missiles they also provide thrust and some lift, and they don't or aren't supposed to fall off I hope. Now onto the military application.
I assume you are asking about jet fighters, of the air to air variety, such as the Su-27 and F-22. I can see why you think that these planes' wings are small, but actually comparing their wing to body ratio will reveal that it's not much smaller and sometimes greater than that of the airliner. However, you are correct in thinking that the purpose is different, and obviously the wing would be designed to reflect that different purpose. Mainly, jet fighters operate at a FAAR greater range of speeds than airliners, and much more routinely surpass speed barriers that introduce significant aerodynamic challenges. The sound barrier isn't the only one, but it's probably the easiest to explain so I will use this as an example. Subsonic air (airflow slower than the speed of sound at altitude) acts in a different manner than supersonic air, introducing wave shock, and exaggerating problems that can arise due to stagnant flow, etc. In addition to utilizing several mechanisms to avoid these issues such as vortex generators and intake splitters, the design of the wings themselves must be modified. To eliminate problems that increase in severity as you approach Mach 1, including destructive vibration, Mach tuck, and tens of other issues, the wing (as well as the rest of the plane) has to be shaped to increase its critical Mach number, a value that pretty much describes the behaviour of the airflow around the airfoil or wing. Otherwise you will encounter stupid large amounts of drag and more often than not stall out due to an absence of airflow over control surfaces. Again if you want me to delve more into the physics of this let me know, I just am short on time right now. The other factor going into the smaller/different wing is wing loading and maintenance, two smaller factors that I feel are more related than not. In short, the fighter's wing will undergo a lot more G's and other strain in different directions due to the much larger flight envelope (the types and numbers of maneuvers that the aircraft can and has to perform) which necessitates a different type of wing.
How we actually see this disparity in role reflected in aircraft can be through a more swept wing, delta wings (best for supersonic flight), variable-geometry wings (F-14), or even completely straight wings for maneuverability at slower speeds (A-10). I suppose it's best to say that there are a whole many more types of roles a military aircraft can fill, compared to short or long distance hauls for civilian aircraft, and this reflects the sometimes smaller wing sizes found on military specimens.
[Edit] Some military aircraft have more than twice the wing to body ratio, such as the U-2/TR-1 spy plane that airliners possess. Just goes to show that the military requires a greater range of designs to fulfill a greater amount of applications. Performance isn't limited to speed or maneuverability.