When you foul you need to be able to take your penalty as quickly as possible so that you can get back in the race. First, know the rule for the event your are sailing. The Racing Rules of Sailing 44.1 stipulates a "Two-Turns Penalty." 44.2 states that the boat must make "the required number of turns in the same direction, each turn including one tack and one jibe." Some events modify 44.1 and require only one turn. This is true for all Ideal 18 racing at Pequot Yacht Club.
You can complete a penalty turn in either direction, and it does not matter whether you tack first or jibe first. In dinghies, sailors often tack first sailing upwind and jibe first sailing downwind. In keel boats, where the boat slow out of a tack, it may make sense to always jibe first using the speed you have, then tack, then sail straight afterwards to build speed. The decision is also situational. You must turn promptly, and stay clear of other boats while taking a penalty turn, therefore you may decide to turn whichever direction facilitates adherence to the rule, lest you break another rule and have to spin again.
To turn the boat efficiently, you need to use weight and sails, and minimal rudder. Imagine a turn to port where you are sailing upwind and will jibe first. Begin the turn by having both skipper and crew hike hard to windward (starboard). Keep the jib trimmed at first, and then ease slowly, always full of wind, so the jib is helping the boat bear away. Ease the main aggressively. As the boat bears away, keep your body weight on the starboard side for the jibe. After the jibe, the crew remains to starboard (now the leeward side). The skipper completes their usual jibing hand switch, but remains standing in the middle (as opposed to crossing the boat and sitting down) to keep the boat heeling to starboard (now leeward) thereby helping the boat continue to turn. The crew slowly trims the jib, allowing about 6" of luff in the jib as the boat turns. This way the jib is not fighting the boat's effort to turn to windward. The skipper trims the mainsail aggressively, still standing in the center to help the boat continue heeling to leeward (starboard). Once on close hauled, the skipper and crew roll the boat to windward together (roll to port) to execute a roll tack. The skipper flattens and sits on the new windward rail (starboard). The crew sits in the appropriate place for the conditions, always aiming for 5-10 degrees of leeward heel for upwind sailing.
The skills above are the same, but begin at a different point in the turn. This time you are already sailing down wind, rather than turning to down wind. Imagine a turn to port where you are sailing down wind and will jibe first. There is no spinnaker in this situation. Begin the turn by the skipper and crew rolling the boat to windward and jibing. After the jibe, the crew remains to leeward (starboard). The skipper completes their usual jibing hand switch, but remains standing in the middle (as opposed to crossing the boat and sitting down) to keep the boat heeling to starboard (now leeward) thereby helping the boat continue to turn. The crew slowly trims the jib, allowing about 6" of luff in the jib as the boat turns. This way the jib is not fighting the boat's effort to turn to windward. The skipper trims the mainsail aggressively, still standing in the center to help the boat continue heeling to leeward (starboard). Once on close hauled, the skipper and crew roll the boat to windward together (roll to port) to execute a roll tack. The skipper and crew both flatten, sit on the new windward rail (starboard), and hike hard to drive the boat to leeward. The crew eases the jib slowly, always full of wind, so the jib is helping the boat bear away. The skipper ease the main aggressively. Once on course the crew moves to leeward if sailing a reach, or flies the jib to windward if sailing a wing on wing course.
If you are sailing with a spinnaker, you MUST take it down before attempting a penalty turn. Advanced crews will drop the spinnaker half way and the crew will hold the sail there while the turn happens, and then put it back up after the turn. Beginner crews should take the sail all the way down.