We monitored the BL Lac object S5 0716+714 in the optical band during the period November 1994-April 1995, which includes the time of a gamma-ray observation by the Energetic Gamma Ray Experiment Telescope (EGRET) on February 14--28, 1995. The light curves in the R and B bands show fast fluctuations superimposed on longer timescale variations. The color index correlates with intensity during the rapid flares (the spectrum is flatter when the flux is higher), but it is rather insensitive to the long term trends. Over the 5 month observational period the light curve shows an overall brightening of about 1 mag followed by a fast decline. The EGRET pointing covers part of the very bright phase (V about 13.2) and the initial decline. An ultraviolet spectrum was also obtained with the International Ultraviolet Explorer (IUE) (1200-3000 A) during the EGRET observations. The variability of the optical emission of S5 0716+714 by itself sets important constraints on the magnetic field strength and on the physical processes responsible for it. Interpreting the whole electromagnetic spectrum with synchrotron self Compton models leads to the prediction of a bright gamma-ray state during the EGRET pointing. We discuss how the gamma-ray data could be used as a diagnostic of the proposed models. ; Comment: 13 pages, LateX, 10 figures (included). Uses l-aa.sty and epsf.sty. To appear in A&A