Pups (young pigs) can be difficult to sex. Waiting until two or three weeks of age may allow the pig to mature enough to make a determination easier. Small young male pigs have a donut shape to their rectum, totally round or slightly oval, and at the top of this donut, a little dot (sometimes described as an "i"). Some people find they can feel the ridge of the penis under the skin just above the genitals.
Or place your index finger and thumb on either side of the genitals, gently spreading the area -- not much happens with a boy, but with a sow a definite Y appears and the base of the Y (under the "V") will spread quite a bit. Some females will have what has been described as a "pimple" (which might be confused with the dot described above).
Another method is to place your finger directly above the opening and push inward and slightly downward, gently but firmly. If absolutely nothing pops out then it is likely to be a female. Determining sex of a very young cavy can be a challenge because their genitals are so small. If you have an opportunity to examine a few pigs, it may be easier to see the differences when you have both sexes to compare.
If in doubt consult your vet !!! Do not risk an unwanted pregnancy.
http://www.cavyspirit.com/sexing.htm - This is an excellent link with full colour photos